2010-10-02 91 views
1

我使用schtasks實用工具在Windows-XP上安排了一項任務,但該任務未運行。以下是我看到SchedLgU.Txt日誌文件:爲什麼「schtasks」不能運行我的工作?

"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的輸出中意味着什麼?

謝謝!

回答

5

我找到了答案:

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

我有我的任務通過C#代碼添加。我可以在「任務計劃程序」中將該操作作爲exe的完整路徑。但是,當時間到了執行它不工作,下一個任務時間顯示。 cmd中的schtasks/query表示「無法啓動」爲狀態。什麼應該是錯誤的? – 2013-03-01 10:16:40

+0

哇,這讓我走上了正軌。使用\「爲內部引號。請參閱http://stackoverflow.com/questions/16723940/powershell-add-task-to-run-powershell-script-with-parameters/16737858#16737858 – Brent 2013-05-24 14:56:04