本帖最后由 yapda 于 2017-1-13 22:44 编辑
- option Explicit
- dim wmi,proc,procs,proname,flag,WshShell
- Do
- proname="QQ.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 ("D:\Tencent\QQ.exe")
- end if
- wscript.sleep 50000 '检测间隔时间,这里是50秒
- loop
复制代码 我只需要尝试启动两次 如果第一次未能启动就结束掉3个进程 然后第二次启动 50秒后检测成功就退出这个vbs 不成功就执行重启命令 |