说明:
使用taskllist 监控进程列表,如果xx.exe进程不在进程列表中,则执行hello.bat启动进程。
其中choice /t 10 /d y /n >nul 表示等待10秒。
@echo off
set AppName=xx.exe
set AppPath=C:\Users\14387\AppData\Roaming\xx\
title monitor
cls
echo.
echo start
echo.
:startjc
tasklist |findstr /i %AppName% >nul
if %errorlevel%==0 (
echo ^>%date:~0,10% %time:~0,8% Program is running......
)else (
echo ^>%date:~0,10% %time:~0,8% cannot find Program
echo ^>%date:~0,10% %time:~0,8% now restart Program
start hello.bat
)
choice /t 10 /d y /n >nul
goto startjc
@echo on
title xx
set AppName=xx.exe
set AppPath=C:\Users\14387\AppData\Roaming\xxx\
start %AppPath%%AppName% 2>nul && echo ^>%date:~0,10% %time:~0,8% start Program success!
exit