批处理文件手动而不是运行在任务调度 [英] Batch File runs manually but not in task scheduler
问题描述
我有一个批处理文件,它会搜索java进程并杀死一样。
当BAT文件在命令提示符下运行该脚本正常工作。但是,当我试着在任务调度程序来执行,这是行不通的。
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 )
我自己也尝试无论是在这个环节提到
<一href=\"http://stackoverflow.com/questions/12513264/batch-runs-manually-but-not-in-scheduled-task\">Batch手动而不是运行在计划任务
任何其他建议,请。
请注意:我还有一个批处理文件来存档文件正确运行的任务计划程序使用相同的用户帐户
Note: I have another batch file to archive files which runs properly in task scheduler with the same user account
推荐答案
最后我能找出问题。
它工作时,我未选中选项开始,只有当计算机处于开启条件下的AC电源的任务属性选项卡,结合使用的其他建议,纲要为
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
和添加参数作为
/c C:\mypath\myFile.bat
和在启动为
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 :)
这篇关于批处理文件手动而不是运行在任务调度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!