I have a batch file, which will search for a java process and kill the same.
The script works fine when the bat file is run on the command prompt. But when I tried to execute in task scheduler, it is not working.
I have selected the option "Run whether the user is logged in or not"
My batch file is as given below:
for /F "tokens=1*" %%i in ('jps -lv^|C:\Windows\System32\find.exe "TaskTest"') do (C:\Windows\System32\taskkill.exe /F /PID %%i )
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
and 'Add Arguments' as
and 'Start in' as
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 :)