Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675
WMI with IronPython - IronPython Cookbook

WMI with IronPython

From IronPython Cookbook

Line 64: Line 64:
def showAll(root):
def showAll(root):
-
     nsClass = ManagementClass(ManagementScope(root), ManagementPath("__namespace"), None)
+
     scope = ManagementScope(root)
 +
    path = ManagementPath("__namespace")
 +
    nsClass = ManagementClass(scope, path, None)
     for namespace in nsClass.GetInstances():
     for namespace in nsClass.GetInstances():
         print "-----"
         print "-----"
         for nsProp in namespace.Properties:
         for nsProp in namespace.Properties:
             print str(nsProp.Name), ":", str(nsProp.Value)
             print str(nsProp.Name), ":", str(nsProp.Value)
-
    print "--"
+
        print "--"
-
    scope = ManagementScope("root\\" + str(namespace.GetPropertyValue("Name"))),
+
        scope = ManagementScope("root\\" + str(namespace.GetPropertyValue("Name")))
-
                            WqlObjectQuery("select * from meta_class")
+
        searcher = ManagementObjectSearcher(scope, WqlObjectQuery("select * from meta_class"), None)
-
    searcher = ManagementObjectSearcher(scope, None)
+
        for wmiClass in searcher.Get():
-
    for wmiClass in searcher.Get():
+
            print "Class:", wmiClass.GetPropertyValue("__CLASS")
-
        print "Class:", wmiClass.GetPropertyValue("__CLASS")
+
   
   
showAll('root')
showAll('root')

Revision as of 18:12, 26 December 2007

TOOLBOX
LANGUAGES