香港新浪網 MySinaBlog
« 上一篇 | 下一篇 »
Emily | 30th Nov 2006, 23:07 PM | Script | (1459 Reads)

WMI Example: Win32_Process

All Windows Platforms

 

Sub Ex1()
For Each Process In GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_process")
     Debug.Print Process.Name
Next
End Sub

Sub Ex2()

strServer = "."
Set objWMI = GetObject("winmgmts://" & strServer & "/rootcimv2")
Set objInstances = objWMI.InstancesOf("Win32_Process", 48)

For Each objInstance In objInstances
   Debug.Print objInstance.getObjectText_
Next
End Sub

 

Sub Ex3()
strServer = "."
Set objWMI = GetObject("winmgmts://" & strServer & "/rootcimv2")
Set objInstances = objWMI.InstancesOf("Win32_Process", 48)

On Error Resume Next
For Each
objInstance In objInstances
    With objInstance
        Debug.Print .Caption
        Debug.Print .CommandLine
        Debug.Print .CreationClassName
        Debug.Print .CreationDate
        Debug.Print .CSCreationClassName
        Debug.Print .CSName
        Debug.Print .Description
        Debug.Print .ExecutablePath
        Debug.Print .ExecutionState
        Debug.Print .Handle
        Debug.Print .HandleCount
        Debug.Print .InstallDate
        Debug.Print .KernelModeTime
        Debug.Print .MaximumWorkingSetSize
        Debug.Print .MinimumWorkingSetSize
        Debug.Print .Name
        Debug.Print .OSCreationClassName
        Debug.Print .OSName
        Debug.Print .OtherOperationCount
        Debug.Print .OtherTransferCount
        Debug.Print .PageFaults
        Debug.Print .PageFileUsage
        Debug.Print .ParentProcessId
        Debug.Print .PeakPageFileUsage
        Debug.Print .PeakVirtualSize
        Debug.Print .PeakWorkingSetSize
        Debug.Print .Priority
        Debug.Print .PrivatePageCount
        Debug.Print .ProcessId
        Debug.Print .QuotaNonPagedPoolUsage
        Debug.Print .QuotaPagedPoolUsage
        Debug.Print .QuotaPeakNonPagedPoolUsage
        Debug.Print .QuotaPeakPagedPoolUsage
        Debug.Print .ReadOperationCount
        Debug.Print .ReadTransferCount
        Debug.Print .SessionId
        Debug.Print .Status
        Debug.Print .TerminationDate
        Debug.Print .ThreadCount
        Debug.Print .UserModeTime
        Debug.Print .VirtualSize
        Debug.Print .WindowsVersion
        Debug.Print .WorkingSetSize
        Debug.Print .WriteOperationCount
        Debug.Print .WriteTransferCount
    End With
On Error GoTo
0
Next
End Sub

'

mySinaBlog 不支援斜線,斜線現用全形\取代 ,請改回。