Web Analytics Made Easy -
StatCounter code to display the running applications on a system - CodingForum

Announcement

Collapse
No announcement yet.

code to display the running applications on a system

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • code to display the running applications on a system

    Hi...I would be grateful if anyone could help me with a code to display the names of "applications" running on a system.

  • #2
    There's a lot of ways to do what you're asking but a simple way would be to use the built in commands that come with the operating system, assuming you're on windows you could use:

    Code:
    import subprocess
    
    cmd = subprocess.Popen("tasklist /NH /FO CSV", shell=True, stdout=subprocess.PIPE)
    procs = str(cmd.communicate()).split()
    
    for x in procs:
        print x
    You'd have to filter out some of the information in the data to just get the process names.

    Comment


    • #3
      Using psutil library we can display the running applications of the system.
      It is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python.

      It is useful mainly for system monitoring, profiling, limiting process resources, and management of running processes.

      Following is the code for display all running applications in the system :
      Code:
      import psutil
      
      for proc in psutil.process_iter():
          try:
              processName = proc.name()
              processID = proc.pid
              print(processName , ' ::: ', processID)
          except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
              pass
      ASP.Net Software Development

      Comment

      Working...
      X