创建2个脚本文件,一个自启动文件start.bat,一个双击关闭文件shutdown.bat,
:: 脚本 start.bat, 循环检测gbcollection.exe,如果退出会自动拉起程序
@echo off
:: 以下这两句是将本批处理放到后台运行
if “%1”==“hide” goto CmdBegin
start mshta vbscript:createobject(“wscript.shell”).run("""%~0"" hide",0)(window.close)&&exit
:CmdBegin
:loop
tasklist | find “gbcollection.exe” >> start.log
if errorlevel == 1 start gbcollection.exe :: start 后面的程序不要用双引号引住,否则启动的程序将会直接在该窗口运行,不会另起一个窗口
timeout /T 3
goto loop
脚本文件shutdown.bat:
::脚本 shutdown.bat, 退出gbcollection.exe脚本,只有运行本脚本才会退出gbcollection.exe,否则无论怎么关闭都关闭不了,关掉都会起来
@echo off
taskkill /f /t /im cmd.exe
taskkill /f /t /im gbcollection.exe
转自:https://blog.csdn.net/sinat_35938012/article/details/119352076?ivk_sa=1024320u
符号>是一次性输出到文件,而>>是将内容追加到文件