天天看点

win 自动重启process

@ECHO OFF 

:check converter.exe                                   

tasklist >list.txt           //将所有进程信息列入list.txt文件里面(这里默认当前目录)

find /i "converter.exe" list.txt     //从list.txt文件里查找java.exe这个进程

if "%errorlevel%"=="1" (goto start) else (goto e)     //如果进程不存在,执行start处的代码;反之执行e处的代码

:e

taskkill /f /im converter.exe                    //杀掉进程

:start

cls

START startup.bat           //开启进程  要与脚本在同一目录下

:check cmd.exe             //由于上面杀进程后会留下cmd.exe没有退出,并一起kill cmd.exe

tasklist >list2.txt  

find /i "cmd.exe" list2.txt     

if "%errorlevel%"=="1" (goto e)  

taskkill /f /im cmd.exe   

:end

exit

at 12:22 /every:m,t,w,th,f,s,su "D:\converter_station\ftpbat.bat“  计划任务

      本文转自crazy_charles 51CTO博客,原文链接:http://blog.51cto.com/douya/1433485,如需转载请自行联系原作者