标题: 求教VBS提示增多或减少正在运行的进程怎样写? [打印本页]
作者: wgmlzj 时间: 2008-10-29 12:10 标题: 求教VBS提示增多或减少正在运行的进程怎样写?
用VBS写,也可以用BAT和VBS结合起来写,用于实时监测进程变化的.(只需显示刚增加或减少的进程则可)
不是列出整个进程表(进程管理器)
谢谢!
[ 本帖最后由 wgmlzj 于 2008-10-29 12:19 编辑 ]
作者: Batcher 时间: 2008-10-29 13:11
增加或减少以哪个数值为基准?
作者: rat 时间: 2008-10-29 14:20
- If WScript.Arguments.Count = 0 Then
- RunExe "cmd /k start /b " _
- & "cscript //nologo " & """" & WScript.ScriptFullName & """" & " MonitorCreation & " _
- & "cscript //nologo " & """" & WScript.ScriptFullName & """" & " MonitorDeletion"
- WScript.Quit
- End If
-
- Execute WScript.Arguments(0)
-
-
-
- Sub RunExe(strPath)
- Dim objWSH
- Set objWSH = CreateObject("WScript.Shell")
- objWSH.Run strPath
- Set objWSH = Nothing
- End Sub
-
- Sub MonitorCreation()
- 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 Now() & " Process Created: " & vbCrLf & objLatestProcess.TargetInstance.CommandLine & vbCrLf
- Loop
- End Sub
-
- Sub MonitorDeletion()
- 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 Now() & " Process Deleted: " & vbCrLf & objLatestProcess.TargetInstance.CommandLine & vbCrLf
- Loop
- End Sub
复制代码
作者: wgmlzj 时间: 2008-10-29 14:48
很好,很好,很有启发,谢谢!
作者: jellyhk 时间: 2008-10-29 17:09
厉害啊!
我看都没看懂!
不过我认为用进程比较就行了吧!
把开始的进程罗列!
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |