Python Forum
New to Python: Looking to run WMI/WMIC Commands from Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: New to Python: Looking to run WMI/WMIC Commands from Python (/thread-14258.html)



New to Python: Looking to run WMI/WMIC Commands from Python - ForensicPython - Nov-21-2018

It would appear I need to import some modules in my Python script to accomplish this but so far no luck.

I also downloaded and installed a WMIC for Python installer I found, not sure if it was needed.

I'd like to be able to run WMI/WMIC commands from my script, such as. WMIC bios

Any hints on how I might accomplish this?


RE: New to Python: Looking to run WMI/WMIC Commands from Python - Larz60+ - Nov-21-2018

The documentation on this site has example code: https://pypi.org/project/WMI/
you can get this package with:
pip install WMI



RE: New to Python: Looking to run WMI/WMIC Commands from Python - ForensicPython - Nov-21-2018

I will dive into this more. I did do the Windows install from that site already. I closed everything and restarted. I've tried running import WMI and using WMIC commands in the Python terminal and through PyCharm and nothing but errors. I'm obviously missing something. Hey, but I can print "Hello" just fine!


RE: New to Python: Looking to run WMI/WMIC Commands from Python - h3xus_ - Jan-03-2019

If you don't want to use WMI module as it's a bit messy, you could in theory start using 'wmic.exe' utility over subprocess library in python; (depends on how heavily you will be using WMI).

Example use:
from subprocess import getoutput as go
But you would need to do a bit of string manipulation afterwards, depending on how precise the query is going to be;
go('wmic /node:127.0.0.1 process list brief')