How can I run a Rake task as a Windows "scheduled task"?

ruby, ruby-on-rails, windows

Solution

If you can build a batch file that can execute it properly I would do so, and then you can direct the batch file to run with the task.

Something like this should work:

:: Run task every hour
@call rake stats RAILS_ENV="production"

Problem

I have a rake task I need to run as a daily job on a Windows XP machine. I discovered the Windows "scheduled tasks" control panel. I'm trying to figure out how to get it to run my Rake task. Two of the fields are "run" (with a browse button) and "start in". I tried to enter `rake mycategory:mytask` into "run" and my Rails project dir containing the Rake task into "start in". The result was a message saying the task "could not start". How can I get set up a Windows "scheduled task" to run a Rake task?

Original source