Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created August 2, 2014 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/fe47452f74bfa2d4b3d0 to your computer and use it in GitHub Desktop.
Save zeffii/fe47452f74bfa2d4b3d0 to your computer and use it in GitHub Desktop.
the mega end task script
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