Windows Task Scheduler doesn't start batch fil

2019-03-12 10:12发布

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

15条回答
戒情不戒烟
2楼-- · 2019-03-12 10:34

For me it was trigger issue. By default it should On a Schedule in trigger tab. I had selected At log on and then I was waiting to run task. As it's name says at log on, means you have to logout and log on.

Try putting it on a Schedule and fire it every minute.

enter image description here

查看更多
smile是对你的礼貌
3楼-- · 2019-03-12 10:38

My application failed to start via "Task Scheduler".

The error in "Event Viewer" is: System.IO.DirectoryNotFoundException

The "Task Scheduler" tries to run this application with the "SYSTEM" user. The problem was that a "network drive" was not mapped for the "SYSTEM" user. So what I did was, I created a ".bat" file and mapped the "network drive" before starting the application:

net use T: \\172.20.2.215\images
cd C:\MyApplication
start MyApplication.exe

So check your logs first: "Event Viewer" -> Windows Logs -> Application

查看更多
Evening l夕情丶
4楼-- · 2019-03-12 10:41

Set 'Program/script' -- > file.bat set 'Start in' the rest of path (file.bat)

查看更多
登录 后发表回答