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