How to use WMI module (only for Windows) In Python

The WMI module can be used to gain system information of a windows machine and can be installed using the below command: 
 

pip install wmi

Example: 
 

Python3




import wmi
 
c = wmi.WMI()   
my_system = c.Win32_ComputerSystem()[0]
 
print(f"Manufacturer: {my_system.Manufacturer}")
print(f"Model: {my_system. Model}")
print(f"Name: {my_system.Name}")
print(f"NumberOfProcessors: {my_system.NumberOfProcessors}")
print(f"SystemType: {my_system.SystemType}")
print(f"SystemFamily: {my_system.SystemFamily}")


Output: 
 

Manufacturer: LENOVO
Model: 80XH
Name: LAPTOP-PRKUI1Q9
NumberOfProcessors: 1
SystemType: x64-based PC
SystemFamily: ideapad 320-15ISK

 

Get Your System Information – Using Python Script

Getting system information for your system can easily be done by the operating system in use, Ubuntu let’s say. But won’t it be fun to get this System information using Python script? In this article, we will look into various ways to derive your system information using Python.

There are two ways to get information:

  1. Using Platform module
  2. subprocess 
     

Similar Reads

1. Using Platform module:

Installation of the platform module can be done using the below command:...

Using WMI module (only for Windows):

...

Using os module (only for Unix):

The WMI module can be used to gain system information of a windows machine and can be installed using the below command:...

Using psutil module:

...

2. Using the subprocess  module:

Example:...