Batch File runs manually but not in task scheduler

限于喜欢 提交于 2019-12-01 12:54:46

Finally I was able to figure out the problem. It worked when I unchecked the option "Start only when the computer is on AC power' under 'Conditions' tab in task properties, combined with the other suggestion of using the 'Program' as

C:\Windows\System32\cmd.exe

and 'Add Arguments' as

/c C:\mypath\myFile.bat

and 'Start in' as

C:\mypath\

This worked when the option 'Run whether user is logged in or not' is selected with 'Run with highest privileges' checked.

Thanks for all those who have spend time to analyse this :)

Why are you searching. We do then test, not test then do.

taskkill /f /im TaskTest&&Echo Task Killed||Echo Task not found

To see what your problem is

taskkill /f /im TaskTest > "%temp%\taskkill.log" 2>&1 &&Echo Task Killed >> "%temp%\taskkill.log" 2>&1|| Echo Task not found >> "%temp%\taskkill.log" 2>&1

and look in taskkill.log.

You may also want to do this in the batch as a diagnostic aid. Echoing out your command line m,ay be useful.

tasklist > "%temp%\taskkill.log" 2>&1 
set > "%temp%\taskkill.log" 2>&1 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!