Advertisement
Python253

win_process_list

May 23rd, 2024
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Filename: win_process_list.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. Description:
  9.    This script retrieves a list of running processes on a Windows system using the 'tasklist' command and prints the output.
  10.  
  11. Requirements:
  12.    - Python 3.x
  13.    - This script is specifically designed for Windows systems.
  14.  
  15. Functions:
  16.    - get_process_list():
  17.      Retrieves a list of running processes on the Windows system and returns the output as a string.
  18.  
  19. Usage:
  20.    - Simply execute the script. It will display the list of running processes in the console.
  21.  
  22. Additional Notes:
  23.    - This script uses the 'tasklist' command, which is a built-in Windows utility for listing running processes.
  24. """
  25.  
  26. import subprocess
  27.  
  28. def get_process_list():
  29.     """
  30.    Retrieves a list of running processes on the Windows system.
  31.  
  32.    Returns:
  33.        str: A string containing the output of the 'tasklist' command.
  34.    """
  35.     tasklist_output = subprocess.check_output(['tasklist'], shell=True)
  36.     return tasklist_output.decode('utf-8')
  37.  
  38. if __name__ == "__main__":
  39.     process_list = get_process_list()
  40.     print(process_list)
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement