WMI with IronPython

From IronPython Cookbook

(Difference between revisions)
(New page: An example from [http://vastusutra.blogspot.com/2007/09/wmi-on-local-system.html Vasta Sutra], of using the managed interface to WMI. This uses objects from the [http://msdn2.microsoft.co...)
Line 1: Line 1:
-
An example from [http://vastusutra.blogspot.com/2007/09/wmi-on-local-system.html Vasta Sutra], of using the managed interface to WMI.
+
An example from [http://vastusutra.blogspot.com/2007/09/wmi-on-local-system.html Vasta Sutra], of using the managed interface to WMI on the local system.
This uses objects from the [http://msdn2.microsoft.com/en-us/library/system.management.aspx System.Management] assembly:
This uses objects from the [http://msdn2.microsoft.com/en-us/library/system.management.aspx System.Management] assembly:

Revision as of 15:35, 26 October 2007

An example from Vasta Sutra, of using the managed interface to WMI on the local system.

This uses objects from the System.Management assembly:

import clr
clr.AddReference("System.Management")
from System.Management import (
    ManagementObject,
    ManagementObjectSearcher
)

mo = ManagementObject("Win32_Processor.DeviceID='CPU0'")
for p in mo.Properties: 
    print p.Name, '=', p.Value

query = ManagementObjectSearcher("Select * from Win32_Processor")
mo = query.Get().GetEnumerator().next()

mo = ManagementObject("Win32_PerfFormattedData_PerfOS_Processor.Name='_total'")
for p in mo.Properties: 
    print p.Name, '=', p.Value


Back to Contents.

TOOLBOX
LANGUAGES