[IronPython] How would you use IronPython with WMI?

Keith J. Farmer kfarmer at thuban.org
Sat Aug 28 03:05:17 CEST 2004


import sys
sys.LoadAssemblyByName("System.Management")
 
from System.Management import *
 
def doSearch(searchString):
    for x in ManagementObjectSearcher(searchString).Get():
        for y in x.Properties:
            print str(y.Name) + ": " + str(y.Value)
        print "-----"
 
doSearch("select name, horizontalResolution, verticalResolution from win32_printer")
 
... I'd never done this sort of thing before.  Thanks :)

________________________________

From: users-ironpython.com-bounces at lists.ironpython.com on behalf of Andy Shah
Sent: Fri 8/27/2004 4:40 PM


How does one use IronPython with WMI ?

I have a short code gleaned from a website

http://www.c-sharpcorner.com/Code/2004/March/WMIEventDetecting.asp

converted to python

from System.Management.Instrumentation import *

f = TestWMI.ROOT.CIMV2.Printer("Canon-Import")

MessageBox.Show(p.Caption)
MessageBox.Show(p.HorizontalResolution.ToString())
MessageBox.Show(p.VerticalResolution.ToString())





More information about the Ironpython-users mailing list