Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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"
share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
1  
Thanks. I had just found the KB article to do just that. Here it is in case anybody else runs across this issue: support.microsoft.com/kb/823093 –  Taylor Leese Feb 26 '10 at 2:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.