批处理 定时检测制定的多个程序进程

2025-03-04 11:31:48
推荐回答(1个)
回答1:

用VBS吧,没黑框,复制下面的代码保存到记事本里,保存为.vbs,后运行,里

option Explicit
dim wmi,proc,procs,proname,flag,WshShell
Do
proname="ClientOfWatcher.exe" '需要监测的服务进程的名称,自行替换这里的记事本进程名
set wmi=getobject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")
set procs=wmi.execquery("select * from win32_process")
flag=true
for each proc in procs
if strcomp(proc.name,proname)=0 then
flag=false
exit for
end if
next
set wmi=nothing
if flag then
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run ("C:\Watcher\ClientOfWatcher.exe") 这里是要执行程序的绝对路径 ,你自己来改
end if
wscript.sleep 50000 '检测间隔时间,这里是50秒
loop