- @echo off
- if "%1" == "h" goto begin
- @REM 强制跳转:begin
- mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit
- :begin
- set _task=foxtable
- set _runexe=start.vbs
-
- :checkstart
- @REM 若进程%_task%存在,则延迟10秒;若进程不存在,则启动程序.反复循环
- echo "检查进程"
- for /f "tokens=5" %%c in ('qprocess.exe ^| find "%_task%"') do ( if %%c==" " ( @echo ) else goto checkag )
- goto startsvr
-
- :startsvr
-
- echo ******开始启动程序*******
-
- echo 启动时间 %time% >> restart.log
- @REM 用start.vbs,隐藏窗口启动程序
- echo set ws=wscript.createobject("wscript.shell") >> %_runexe%
- echo ws.run "foxtable.exe",0,false >> %_runexe%
-
- start /b %_runexe%
-
- @REM 延迟10秒后删除start.vbs,继续检测进程
- echo Wscript.Sleep Wscript.Arguments(0) >%tmp%\delay.vbs
-
- cscript //b //nologo %tmp%\delay.vbs 10000
-
- del %_runexe% /Q
-
- echo *******程序启动完成********
-
- goto checkstart
-
-
- :checkag
- @REM 延迟10秒
- echo Wscript.Sleep Wscript.Arguments(0) >%tmp%\delay.vbs
-
- cscript //b //nologo %tmp%\delay.vbs 10000
-
- goto checkstart
复制代码
|