为什么“schtasks”不能完成我的工作?

时间:2010-10-02 08:55:27

标签: windows-xp scheduled-tasks schtasks.exe

我使用schtasks实用程序在Windows-XP上安排了一项任务,但该任务未运行。以下是我在SchedLgU.Txt日志文件中看到的内容:

"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.

我发现这个错误的原因是我脚本路径中的空格。我用来设置任务的命令如下:

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

例如,如果我用下划线替换空格,问题就会消失。

我怎么能解决这个问题?

另一个问题:
Start In列在schtasks /query /v的输出中的含义是什么?

谢谢!

1 个答案:

答案 0 :(得分:6)

我找到了答案:

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.

即。它应该是这样的:

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