Created
August 2, 2014 15:47
-
-
Save zeffii/fe47452f74bfa2d4b3d0 to your computer and use it in GitHub Desktop.
the mega end task script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, traceback, os | |
import subprocess | |
def pkill(process_name): | |
try: | |
killed = os.system('C:/Windows/System32/TASKKILL /F /IM ' + process_name) | |
except: | |
killed = 0 | |
return killed | |
def find_processes(): | |
try: | |
f = ['C:/Windows/System32/tasklist', '/FI', "SESSIONNAME eq Console"] | |
found_values = subprocess.check_output(f) | |
except: | |
found_values = 0 | |
g = found_values.decode().split('\r\n') | |
return [k.split()[0] for k in g[3:-1]] | |
items = find_processes() | |
for item in items: | |
if not item in {"winlogin.exe", "python.exe"}: | |
pkill(item) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment