I writing a script to automatically kill processes that have a specific user name
. I'm using wmi
library to find all the process and os
to kill processes. I need a way to find the user name
of the process so that I can kill it.
Here's a snippet
import os
import wmi
c = wmi.WMI()
for process in c.Win32_Process():
print(process.ProcessId, process.Name)
def terminate(processName):
os.system('taskkill /IM "' + processName + '" /F')