Board logo

标题: 求教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

  1. If WScript.Arguments.Count = 0 Then
  2. RunExe "cmd /k start /b " _
  3. & "cscript //nologo " & """" & WScript.ScriptFullName & """" & " MonitorCreation & " _
  4. & "cscript //nologo " & """" & WScript.ScriptFullName & """" & " MonitorDeletion"
  5. WScript.Quit
  6. End If
  7. Execute WScript.Arguments(0)
  8. Sub RunExe(strPath)
  9. Dim objWSH
  10. Set objWSH = CreateObject("WScript.Shell")
  11. objWSH.Run strPath
  12. Set objWSH = Nothing
  13. End Sub
  14. Sub MonitorCreation()
  15. strComputer = "."
  16. Set objWMIService = GetObject("winmgmts:" _
  17.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  18. Set colMonitoredProcesses = objWMIService. _        
  19.     ExecNotificationQuery("select * from __instancecreationevent " _
  20.         & " within 1 where TargetInstance isa 'Win32_Process'")
  21. i = 0
  22. Do While i = 0
  23.     Set objLatestProcess = colMonitoredProcesses.NextEvent
  24.     Wscript.Echo Now() & "   Process Created: " & vbCrLf & objLatestProcess.TargetInstance.CommandLine & vbCrLf
  25. Loop
  26. End Sub
  27. Sub MonitorDeletion()
  28. strComputer = "."
  29. Set objWMIService = GetObject("winmgmts:" _
  30.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  31. Set colMonitoredProcesses = objWMIService. _
  32.     ExecNotificationQuery("select * from __instancedeletionevent " _
  33.             & "within 1 where TargetInstance isa 'Win32_Process'")
  34. i = 0
  35. Do While i = 0
  36.     Set objLatestProcess = colMonitoredProcesses.NextEvent
  37.     Wscript.Echo Now() & "   Process Deleted: " & vbCrLf & objLatestProcess.TargetInstance.CommandLine & vbCrLf
  38. Loop
  39. End Sub
复制代码

作者: wgmlzj    时间: 2008-10-29 14:48

很好,很好,很有启发,谢谢!
作者: jellyhk    时间: 2008-10-29 17:09

厉害啊!
我看都没看懂!
不过我认为用进程比较就行了吧!
把开始的进程罗列!




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2