0

Is there any way to terminate an application, for instance Google Chrome, using a python script or command? Additionally, is there any python script/command to stop an application from starting.

1 Answers1

1

You can use Windows taskkill from os.system() inside a Python script like that:

import os
os.system("taskkill /f /im  process_im_goes_here.exe"")

Where /f means forcefully kill the process & /im is the process itself (ImageProcess) which means after that you get to specify the full path to the ImageProcess.

You can also use tasklist to find what processes are currently running.

Here are some taskkill usage examples:

taskkill /pid 1230 /pid 1241 /pid 1253
taskkill /f /fi "USERNAME eq NT AUTHORITY\SYSTEM" /im notepad.exe
taskkill /s srvmain /f /im notepad.exe
taskkill /s srvmain /u maindom\hiropln /p p@ssW23 /fi "IMAGENAME eq note*" /im \*
taskkill /s srvmain /u maindom\hiropln /fi "USERNAME ne NT*" /im \*
taskkill /f /fi "PID ge 1000" /im \*

Alternatively, you can use psutil.

You can learn more about taskkill here and/or python os.system.

Also, this has been answered before

Hope this helped!

nic3ts
  • 347
  • 1
  • 2
  • 13