Do
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = '" & strProcess & "'")
For Each objProcess In colProcess
Flag = Flag + 1
Exit For
Next
Flag = Flag - 1
If Flag = 1 Then
'重新启动程序
Flag = 0
'WSCript.Echo "所监视程序被结束了一次。"
WshSHell.Run strProcess
ElseIf Flag = - 1 Then
'关机
'WSCript.Echo "所监视程序被结束了两次。"
Exit Do
End If
Loop
Set WshSHell = Nothing
Set colProcess = Nothing
Set objWMIService = Nothing作者: slore 时间: 2008-4-4 18:10 缺点:
1.结束wscript就玩完~(这个vbs运行的进程)
2.进程名监视,如果随便搞个exe改成监控的程序名运行
监控失效……