我有一个批处理文件daily.bat,这是代码:

cd C:\inetpub\wwwroot\infoweb\factuur\cron
c:\PHP\php.exe -f ./cron_pdf.php
ftp -s:ftp_upload.txt ftp.site.be

我在Windows 7中用任务调度程序创建了一个任务。当我手动运行批处理时,一切正常,但当我尝试用任务调度程序运行它时,什么也没有发生。

我的行动是

'run script' "C:\inetpub\wwwroot\site\x\cron\daily.bat"

UAC关闭,我是管理员。

知道这为什么不管用吗?


当前回答

如果以上所有步骤都失败了,请确保您试图以用户身份运行任务的用户有权访问您试图使用的文件。

在我的情况下,我试图从C:\Users\Administrator\Desktop运行一个批处理文件,该帐户无法访问。将它移动到C:\的中立位置解决了这个问题。

其他回答

我把这个问题的答案贴在这里和这里。

对于那些bat文件仍然不能在Windows 8和10+任务调度器中工作的人,我想在Ghazi的回答中添加一件事-在经历了许多痛苦之后:

在操作中选择“创建基本任务”,而不是“创建任务”

这对我来说很管用,另外还有其他一些不能忘记的问题:

使用引号,如果你需要,在你的启动程序>程序/脚本条目即“C:\my scripts\runme.bat”(或只是使用浏览按钮)… 使用Start In路径到你的批处理文件,即使它说可选-但不要在Start In字段中使用引号。(这很疯狂,但却是事实!)

这种方法不需要触发命令提示符。这是最快最简单的方法。

(对不起,我的代表太低了,不能把我的基本任务提示添加到Ghazi的评论中)

在Windows7 Pro下,我发现Arun的解决方案对我有用:我可以让它在“没有用户登录”的情况下工作,我确实选择了使用最高特权。

根据过去的经验,您必须有一个带有密码的帐户(空白密码是不好的),如果在您完成向导时程序没有提示您输入密码,请返回并编辑一些内容,直到它提示您输入密码!

这是方法,在情况下,它不清楚的工作

Action: start a program
Program/script : cmd
      (doesn't need the .exe bit!)
Add arguments:
    /c start "" "E:\Django-1.4.1\setup.bat" 

尝试以高权限运行任务。

在“start in folder”路径的末尾放置一个\,例如c:\temp\

我不知道为什么,但有时这对我很有效。

Please check which user account you use to execute our task. It may happen that you run your task with different user then your default user, and this user requires some extra privileges. Also it may happen that the task is executed but you cant see any effect because the batch file waits for some user response so please check task manager if you see your process running. Once it happen that I schedule a batch with svn update of some web page and the process hangs because svn asked for accepting server certificate.