绿色迅雷11老是会莫名退出,不知道什么原因,懒得去反馈和深究。于是有了这个批处理,原理很简单,就是每隔5分钟检查Thunder.ex进程是否存在,如果不存在就运行它:@echo off
mode con cols=48 lines=5
mode con cp select=936>nul
title 守护迅雷进程
color 0a&cls
set "thunder=C:\prog\Thunder Network\Thunder\Program\Thunder.exe"
if not exist "%thunder%" (color 0c&echo;迅雷程序不存在,请修改批处理!&timeout /T 5 >nul&goto END) else (call :GET_PROG_PATH "%thunder%" thunderpath)
set /a "n=0,n1=0"
:LOOP
if %n1% gtr 1000 (color 0c&echo;已重试%n1%次启动迅雷都不成功,本批处理将退出!&timeout /t 600 >nul&goto END)
tasklist /nh /fi "imagename eq Thunder.exe" 2>nul|find /i "Thunder.exe" 1>nul 2>nul
if %errorlevel% equ 0 (
if %n% equ 0 (cls&echo;迅雷运行中...) else (cls&echo;第%n%次启动迅雷!&echo;迅雷运行中...)
set /a "n1=0"
SETLOCAL ENABLEDELAYEDEXPANSION
echo;
choice /C DE /N /T 300 /D D /M "要退出守护请按E:"
if !errorlevel! equ 2 (ENDLOCAL&goto END) else (ENDLOCAL&goto LOOP)
ENDLOCAL
) else (
cls&echo;正在启动迅雷...&set /a "n+=1,n1+=1"
:+ 直接运行Thunder.exe,在运行之后不会返回批处理,直到Thunder.exe进程结束后才返回。
rem "%thunder%"