監(jiān)視進(jìn)程的創(chuàng)建,在每次創(chuàng)建新的進(jìn)程時,臨時事件消費(fèi)程序都發(fā)出警報。
1.監(jiān)視進(jìn)程的創(chuàng)建
復(fù)制代碼 代碼如下:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
"{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("select * from __instancecreationevent " _
" within 1 where TargetInstance isa 'Win32_Process'")
i = 0
Do While i = 0
Set objLatestProcess = colMonitoredProcesses.NextEvent
Wscript.Echo objLatestProcess.TargetInstance.Name
Loop
2.監(jiān)視進(jìn)程的刪除,在每次進(jìn)程終止時,臨時事件消費(fèi)程序都發(fā)出警報。
復(fù)制代碼 代碼如下:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
"{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("select * from __instancedeletionevent " _
"within 1 where TargetInstance isa 'Win32_Process'")
i = 0
Do While i = 0
Set objLatestProcess = colMonitoredProcesses.NextEvent
Wscript.Echo objLatestProcess.TargetInstance.Name
Loop
3.監(jiān)視進(jìn)程使用處理器的情況
復(fù)制代碼 代碼如下:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
"{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_process")
For Each objProcess in colProcesses
sngProcessTime = ( CSng(objProcess.KernelModeTime) + _
CSng(objProcess.UserModeTime)) / 10000000
Wscript
參考鏈接:
- 監(jiān)視進(jìn)程的創(chuàng)建
- 監(jiān)視進(jìn)程的刪除
參考: http://hi.baidu.com/%B1%F9%D0%C4%B3%D5/blog/item/5691a1c3146ded55b219a861.html http://demon.tw/programming/vbs-monitoring-process-creation-and-deletion.html