标题: VBS如何实现监控单个进程的资源使用情况? [打印本页]
作者: rwxyxy 时间: 2009-8-26 16:11 标题: VBS如何实现监控单个进程的资源使用情况?
如何实现Windows脚本监控指定进程的资源占用情况(CPU、内存、虚拟内存),可否告知用到什么对象及实现方法?
作者: fastslz 时间: 2009-8-26 21:44
- If (Lcase(Right(Wscript.FullName,11)) = "wscript.exe") Then
- CreateObject("WScript.Shell").Run("%Comspec% /C " &Chr(34)&"Cscript.exe //NoLogo "&Chr(34)& Wscript.ScriptFullName &Chr(34))
- Wscript.Quit
- End If
-
- aExe = "notepad.exe"
- Set Wmi = GetObject("Winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
-
- Do
- Set A = Wmi.Execquery("Select * From Win32_Process Where Name = '" & aExe & "'")
- For Each B In A
- Wscript.Echo "映像路径:" &vbtab& B.CommandLine
- Wscript.Echo "内存使用:" &vbtab& FormatNumber(B.WorkingSetSize/1024,0) & " K"
- Wscript.Echo "虚拟内存:" &vbtab& FormatNumber(B.PageFileUsage/1024,0)& " K"
- Wscript.Echo
- Next
- Wscript.Sleep 1000
- Loop
复制代码
CPU使用就不知道是哪个属性
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |