


we can read the cmd command through the subprocess module. We will use the subprocess module to interact with cmd and to retrieve information into your python ide. Then we passed the output of the above command to read() in order to get data in readable form out of os._wrap_close object.

We used the function popen() found inside the os module, in order to execute the command in the command processor. The user could pick any other alternatives (Subprocess, shutil etc) which allows for commandline command execution. Note: It is not mandatory to use the os library for the purpose. For the purpose of getting running processes, we would be executing the command: WMIC is a commandline utility that allows users to performs Windows Management Instrumentation (WMI) operations with a command prompt. In this method, we would be using a command found inside the Windows Command Processor (cmd.exe) under the name WMIC ( Windows Management Instrumentation Command line) in order to get the desired result. We used F-strings for the output in order to add padding to the output to align it properly. Then we obtained the ProcessID (pid) and ProcessName (name) of the process using the associated attributes. Then we called the function WMI.Win32_Process() to get the running processes, iterated through each process and stored in variable process.

We would be using the WMI.Win32_Process function in order to get the list of running processes on the system. This allows us to use the functions found inside it such as WMI.Win32_Service, WMI.Win32_Process, WMI.Win32_Printjob which are designed to perform different tasks.
