Batch File runs manually but not in task scheduler

前端 未结 2 1924
时光取名叫无心
时光取名叫无心 2020-12-20 01:04

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 execut

2条回答
  •  抹茶落季
    2020-12-20 01:47

    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 
    

提交回复
热议问题