Board logo

标题: VBS如何实现监控单个进程的资源使用情况? [打印本页]

作者: rwxyxy    时间: 2009-8-26 16:11     标题: VBS如何实现监控单个进程的资源使用情况?

如何实现Windows脚本监控指定进程的资源占用情况(CPU、内存、虚拟内存),可否告知用到什么对象及实现方法?
作者: fastslz    时间: 2009-8-26 21:44

  1. If (Lcase(Right(Wscript.FullName,11)) = "wscript.exe") Then
  2.    CreateObject("WScript.Shell").Run("%Comspec% /C " &Chr(34)&"Cscript.exe //NoLogo "&Chr(34)& Wscript.ScriptFullName &Chr(34))
  3.    Wscript.Quit
  4. End If
  5. aExe = "notepad.exe"
  6. Set Wmi = GetObject("Winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
  7. Do
  8. Set A = Wmi.Execquery("Select * From Win32_Process Where Name = '" & aExe & "'")
  9. For Each B In A
  10. Wscript.Echo "映像路径:" &vbtab& B.CommandLine
  11. Wscript.Echo "内存使用:" &vbtab& FormatNumber(B.WorkingSetSize/1024,0) & " K"
  12. Wscript.Echo "虚拟内存:" &vbtab& FormatNumber(B.PageFileUsage/1024,0)& " K"
  13. Wscript.Echo
  14. Next
  15. Wscript.Sleep 1000
  16. Loop
复制代码


CPU使用就不知道是哪个属性




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