批处理打造系统服务监控器

 

@echo off
title 系统服务监控 By lxzzr QQ:373754376
mode con:cols=50 lines=2
md c:\temp
if not exist c:\temp\fuwu.txt for /f "skip=1 delims= " %%a in ('wmic Service get name') do echo %%a>>c:\temp\fuwu.txt
attrib +h c:\temp\fuwu.txt
:a
CLS
if exist c:\temp\sleep.vbs del c:\temp\sleep.vbs /a:h /q
echo wscript.sleep 3000>c:\temp\sleep.vbs
attrib +h c:\temp\sleep.vbs
cscript c:\temp\sleep.vbs >nul
del c:\temp\sleep.vbs /a:h /q
for /f "skip=1 delims= " %%a in ('wmic Service get name') do find /i "%%a" c:\temp\fuwu.txt >nul || call :b %%a
goto :a
:b
set /p user=未知服务%1正在被安装,是否删除?[Y,N]
if "%user%"=="Y" wmic path Win32_Service where name="%1" call stopservice >nul & wmic path Win32_Service where name="%1" delete >nul
if "%user%"=="y" wmic path Win32_Service where name="%1" call stopservice >nul & wmic path Win32_Service where name="%1" delete >nul
if "%user%"=="N" echo %1>>c:\temp\fuwu.txt
if "%user%"=="n" echo %1>>c:\temp\fuwu.txt
goto :a