Windows Scheduled Task – “could not start”

scheduled-taskwindowswindows-xp

I'm trying to add a task to the windows task scheduler, but the path for my .exe is in a directory with spaces so it cannot find the file. It gives me an error of "could not start" and in the log it shows "cannot find the file specified". If I manually edit the "Run" location to place the full path in quotes then it works fine. However, I need to be able to add the tasks via command line because I'm running the command as part of a .NET installer. Any ideas how I can accomplish this?

Here is the command I'm running:

C:\> schtasks /tn "My Utility" /sc daily /st 00:00:00 /ru System /tr "C:\Program Files\My Folder\some.exe"

This adds the task fine but the run location ends up being:

C:\Program Files\My Folder\some.exe

— rather than —

"C:\Program Files\My Folder\some.exe"

Best Answer

The command you listed in your posting fails with a command syntax error.

Running the command below on a Windows XP SP3 machine works for me (when I create a folder named "C:\Program Files\My Folder" and put an EXE in that folder named "some.exe"):

schtasks /Create /tn "My utiltiy" /sc daily /st 00:00:00 /ru System /tr "\"C:\Program Files\My Folder\some.exe\""

Escaping the double-quotes seems to do the trick.