Why "schtasks" does not run my job?
Asked Answered
D

1

2

I scheduled a task on Windows-XP using schtasks utility, but the task does not run. Here is what I see in the SchedLgU.Txt log file:

"MySQL Automatic Backup.job" (WampServer) 10/2/2010 6:36:43 PM ** ERROR **
Unable to start task.
The specific error is:
0x800700c1: (Unable to find an error message)
Try using the Task page Browse button to locate the application.

I found out that the reason for this error is spaces in the path to my script. The command that I used to set up the task look like:

schtasks /create /tn "MySQL Automatic Backup" 
         /tr "d:\path with spaces to my script\my script.bat" /sc daily ... 

If I replace the spaces with underscores, for example, the problem disappears.

How could I solve this problem ?

And another question:
What does the Start In column means in the output for schtasks /query /v ?

Thanks !

Dymoke answered 2/10, 2010 at 8:55 Comment(0)
D
6

I found the answer:

Spaces in file paths can be used by using two sets of quotes, 
one set for CMD.EXE and one for SchTasks.exe. 
The outer quotes for CMD need to be double quotes; 
the inner quotes can be single quotes or escaped double quotes.

i.e. it should be like this:

schtasks /create /tn "MySQL Automatic Backup" 
         /tr "\"d:\path with spaces to my script\my script.bat\"" /sc daily ... 
Dymoke answered 2/10, 2010 at 13:39 Comment(2)
I have my task added through c# code. I can c the action as the full path of the exe in "task scheduler". But still when time comes for execution it doesnt work and the next task time is shown. The schtasks /query in cmd says "could not start" as status. What should be wrong???Gt
Wow this led me down the right track. Using \" for inner quotes. See #16724440Pinhead

© 2022 - 2024 — McMap. All rights reserved.