Windows任务计划程序无法启动批处理文件任务 [英] Windows Task Scheduler doesn't start batch file task
问题描述
我有以下code一个批处理文件来停止和启动SQL服务报告:
I have a batch file with the code below to stop and start the SQL Report service:
net stop "SQL Server Reporting Services (MSSQLSERVER)"
timeout /t 10
net start "SQL Server Reporting Services (MSSQLSERVER)"
我已经设置了计划任务每天运行,它目前运行与设置的最高权限系统。我已经建立了在行动的文件夹选项开始,一般都似乎是正确设置。但是,当我运行好像没有什么任务,它说运行任务,但我不能看到,因为它是为了服务已重新启动。
I have set up the scheduled task to run daily, it currently runs as SYSTEM with the highest privileges set. I have set up the start in folder option on the action, and everything generally seems to be set up correctly. But when I run the task nothing seems to happen, it says the task has run but I cant see that the service has been restarted as it is meant to.
有人能告诉我,我缺少的是什么?谢谢
Can someone direct me to what I am missing? Thanks
推荐答案
请确保您正确设置开始在和程序/脚本选项。如果你的文件地址是:C:\\ TEMP \\ foo.bat,设置选项中起步,C:\\ TEMP和程序/脚本选项设置为foo.bat
Make sure you set the 'Start in' and 'Program/script' options correctly. If your file address is: C:\Temp\foo.bat, set the 'start in' option to 'C:\Temp' and the 'Program/script' option to 'foo.bat'.
要设置'开始在'选项:右键单击任务计划程序任务>性状>操作>编辑。
To set the 'Start in' option: Right click task in the task scheduler > Properties > Actions > Edit.
如果仅此不工作,然后尝试.bat文件移动到基本权限的目录(也许例如共享目录)。
If this alone doesn't work then try moving the .bat file to a directory with basic permissions (maybe a shared directory for example).
我在我的.bat文件位于与它的一些限制性的权限的文件夹中,这样只有我的用户帐户可以访问它的一个问题。尽管我已经建立了任务调度使用我的凭据它还是失败了。移动.bat文件到另一个目录排序的问题。
I had a problem where my .bat file was located in a folder with some restrictive permissions on it, so that only my user account could access it. Even though I had set up the task scheduler to use my credentials it still failed. Moving the .bat file to another directory sorted the issue.
这篇关于Windows任务计划程序无法启动批处理文件任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!