#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    42
    Rep Power
    3

    Is there a way to close application/program on windows via Python


    Hi, I'm curious about is there a way to close application on Windows by coding via Python? As far as I know, we can use os to open the path or application directly but I couldn't find the way to close the application by coding from Python yet. Is it possible to do that or not? Please help, thank you
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    Use taskkill
    (taskkill is a command line windows program. There are a few)
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    42
    Rep Power
    3
    Oh thank you, I did try but looks like the application is still showing, here's what i tried:

    os.system("start notepad.exe")

    os.system("taskkill notepad.exe")

    the notepad is still showing on my screen, am I using taskkill right? or wrong? Thank you so much for your answer.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    Can you not be troubled to actually investigate how the command should be used????? These examples were easily found on the internet:
    Code:
    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 *
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo