Created
July 23, 2020 04:55
-
-
Save 0x2a94b5/e82f6e3cd1041fca545dae0b598b7cc4 to your computer and use it in GitHub Desktop.
Revisions
-
0x2a94b5 created this gist
Jul 23, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Termainate an application on windows # from subprocess import run, CalledProcessError def taskCheck(name): cmd = "tasklist | findstr %s" % name try: run(cmd, shell=True, check=True) except CalledProcessError: return False return True def taskKill(name): cmd = "taskkill /F /IM %s /T > nul" % name try: run(cmd, shell=True, check=True) except CalledProcessError: return False return True if __name__ == '__main__': name = "edge.exe" if taskCheck(name): if taskKill(name): print("Successfully terminate %s." % name)