- [查找进程间隔时间.vbs]
- Option Explicit
- Dim a,b
- a=inputbox ("输入要查找的进程名")
- b=inputbox ("输入间隔时间:(单位:毫秒)")
- Dim processName
- processName = a ' 要查找的进程名
-
- Do
- If CheckProcess(processName) Then
- WScript.Echo "进程 " & processName & " 正在运行"
- Else
- WScript.Echo "进程 " & processName & " 未找到"
- End If
-
-
- WScript.Sleep b
- Loop
-
- Function CheckProcess(processName)
- Dim objWMIService, colProcessList, objProcess
- Dim found
- found = False
-
- Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
- Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name='" & processName & "'")
-
- For Each objProcess in colProcessList
- found = True
- Exit For
- Next
-
- CheckProcess = found
- End Function
复制代码
|