Using WMI in Python
Two steps
- Install pywin32 to support wmi commands
- import wmi in python code
INSTALL PYWIIN32
- Open Python Terminal
- Type pip install pywin32 and press enter. This will install pywin32
Like anyother import command you just need to use import wmi. Below is the sample code which get the list of services that is in stopped state (not running )
import wmi c = wmi.WMI () for s in c.Win32_Service (): if s.State == 'Stopped': print(s.Caption, s.State)
No comments:
Post a Comment