
CODE: [Copy to clipboard]不过不好用,可能会漏,还不如自己查询:sProcess = "iexplore.exe"
Set oWMI = GetObject("Winmgmts:")
Set oExec = oWMI.ExecNotificationQuery( _
"Select * From __instanceCreationEvent " & _
"WithIn 1 Where TargetInstance ISA 'Win32_Process'")
Do
Set oNextEvent = oExec.NextEvent
sName = oNextEvent.TargetInstance.Name
If sProcess = LCase(sName) Then
MsgBox sName
End If
Loop
CODE: [Copy to clipboard]这个我在CSDN也帮人解答过,刚好直接转过来。Do
For Each x In GetObject("Winmgmts:Win32_Process").Instances_
If "iexplore.exe" = LCase(x.Name) Then
WScript.Echo x.Name
End If
Next
WScript.Sleep 200
Loop
| Quote: | |
|
CODE: [Copy to clipboard]试试这个,理论上来说应该比那个要节省一些资源,sleep时间你可以自己调整。Set oWMI = GetObject("Winmgmts:")
Set oRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colProcess = oRefresher.AddEnum(oWMI,"Win32_Process").ObjectSet
Do
oRefresher.Refresh
For Each x In colProcess
WScript.Echo x.Name
Next
WScript.Sleep 200
Loop
| Quote: | |
|
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |