-1

Let's suppose 3 applications are open on windows 7.

First,

  • I want to print the process ids of the running applications.

Second,

  • I want to kill the selected application.

How can this be done using python.

The purpose is to make an application which kills the selected process.

Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321
Ui-Gyun Jeong
  • 143
  • 1
  • 4
  • 14

1 Answers1

2

This will find all the chrome pids and kill them, it is cross platform:

import psutil
for p in psutil.process_iter():
    if p.name == "chrome":
        print (p.pid)
        p.kill()

There are lots of examples here

Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321