0
我在写一个vb脚本来监视一个进程。该脚本监视过程的状态,如果该进程没有因为10分钟运行它应该执行一个command.Below是我的脚本:需要监视一个进程
set objWMIService = GetObject ("winmgmts:")
foundProc = False
procName = "calc.exe"
Dim wshell
' Initialise the shell object to return the value to the monitor
Set wshell = CreateObject("WScript.Shell")
if err.number <> 0 then
WScript.Echo "Error: could not create WScript.Shell (error " & err.number & ", " & err.Description & ")"
WScript.quit(255)
end if
for each Process in objWMIService.InstancesOf ("Win32_Process")
If StrComp(Process.Name,procName,vbTextCompare) = 0 then
foundProc = True
procID = Process.ProcessId
End If
Next
#####code to check the proces status
If foundProc = True Then
WScript.Quit(0)
Else
WScript.sleep(1*60*1000)
If foundProc = True Then
WScript.Echo "Found Process (" & procID & ")"
Else
WScript.Echo "Process not running since 10 mins"
WScript.Quit(0)
End If
End If
我有查询,如果我执行脚本,如果假设进程停止一分钟脚本eexcutes后。下一次迭代将在10分钟后检查状态。所以9分钟的差距是巨大的。我需要连续监视它,并且应该在10分钟后开始执行命令。 – rahnik67