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 78: Line 78:
   
   
showAll('root')
showAll('root')
 +
</pre>
 +
 +
 +
This fourth example is converted from C# from the [http://msdn2.microsoft.com/en-us/library/system.management.managementeventwatcher.aspx ManagementEventWatcher] page:
 +
<pre>
 +
import clr
 +
clr.AddReference('System.Management')
 +
from System.Management import *
 +
 +
from System import TimeSpan
 +
 +
 +
query = WqlEventQuery("__InstanceCreationEvent", TimeSpan(0, 0, 1), "TargetInstancece isa \"Win32_Process\"")
 +
 +
watcher = ManagementEventWatcher()
 +
watcher.Query = query
 +
watcher.Options.Timeout = TimeSpan(0, 0, 5)
 +
 +
e = watcher.WaitForNextEvent()
 +
 +
instance = e['TargetInstance']
 +
 +
for entry in instance.Properties:
 +
    print entry.Name, entry.Value
</pre>
</pre>
Back to [[Contents]].
Back to [[Contents]].

Revision as of 23:21, 27 March 2008

TOOLBOX
LANGUAGES