Skip to main content

Windows Management Instrumentation

Project description

Windows Management Instrumentation (WMI) is Microsoft's implementation of
Web-Based Enterprise Management (WBEM), an industry initiative to provide
a Common Information Model (CIM) for pretty much any information about a
computer system.

The Python WMI module is a lightweight wrapper on top of the pywin32
extensions, and hides some of the messy plumbing needed to get Python to
talk to the WMI API. It's pure Python and should work with any version of
Python from 2.1 onwards (list comprehensions) and any recent version of pywin32.

What's new in 1.0 - Highlights

* Refactoring of WMI namespace, classes and instances means that WMI classes
are now first-class objects, which makes certain things easier -- such as
watching for changes -- and certain things possible -- such as calling .Create
on a Win32_ScheduledJob.

c = wmi.WMI ()
pid, result = c.Win32_Process.Create (CommandLine="notepad.exe")
for p in c.Win32_Process (ProcessId=pid):
p.Terminate ()

* Additions to WMI method signatures including the privileges necessary to run
them and the underlying Win32 API calls which they represent. Simply print the
method as an object for its signature and privs, and look at its provenance
property.

c = wmi.WMI ()
opersys = c.Win32_OperatingSystem ()[0]
print opersys.Reboot
#
# <function Reboot () => (ReturnValue) | Needs: SeShutdownPrivilege>
#

* Module-level connect method (for which WMI is an alias) allows connection by
any valid combination of machine name, username, password, security context etc.
It simply gathers into one function nearly all the parameters previously
available under the WMI () or connect_server () functions. At least in theory,
all previous examples using wmi.WMI (...) should still work.

c = wmi.WMI (computer="other_machine", user="tim", password+"secret")

* When connecting to WMI you can specify that the list of classes not be
generated. While this list is useful for interactive work, it does slow down the
initial connection:

c = wmi.WMI (find_classes=False)

* Sundry other small fixes, additions and accretions.

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page