【问题标题】:Why "schtasks" does not run my job?为什么“schtasks”不能运行我的工作?
【发布时间】:2011-04-20 04:34:21
【问题描述】:

我在 Windows-XP 上使用 schtasks 实用程序安排了一项任务,但该任务没有运行。这是我在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 的输出中是什么意思?

谢谢!

【问题讨论】:

    标签: windows-xp scheduled-tasks windows-task-scheduler


    【解决方案1】:

    我找到了答案:

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

    【讨论】:

    • 我通过 c# 代码添加了我的任务。我可以在“任务调度程序”中将该操作作为 exe 的完整路径。但是当执行时间到了,它仍然不起作用,并显示下一个任务时间。 cmd 中的 schtasks /query 将“无法启动”作为状态。应该有什么问题???
    • 哇,这让我走上了正确的道路。使用 \" 作为内引号。见stackoverflow.com/questions/16723940/…
    猜你喜欢
    • 2017-07-11
    • 2013-05-14
    • 1970-01-01
    • 2012-01-13
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2012-01-15
    相关资源
    最近更新 更多