process - Simulate keyboard interrupt to gracefully exit task in Windows?

06
2014-04
  • V_H

    I have a process that doesn't behave when I do a taskkill -f, but the only option taskkill gives me is to kill it with -f.

    When I have the exe running in the Command Prompt I can hit Ctrl + C twice and it exits gracefully with a keyboard interrupt message (it's a Python compiled exe).

    How can I simulate this behavior from the command line?

  • Answers
  • JdeBP

    That depends from what command-line tools you have. If you have JP Software's TCC/LE, you just activate the running program's console's window with the ACTIVATE command and then use the KEYSTACK command to simulate that keystroke as input to the window with:

    KEYSTACK Ctrl-C

    Of course, if your program does not actually have a console when run, you do not have the option of simulating pressing Ctrl+C in its console. ☺


  • Related Question

    How can I kill a process from the command prompt on Windows NT?
  • Manga Lee

    How can I kill a process from the command prompt on Windows NT? Preferably with a tool that comes with the operating system.


  • Related Answers
  • Dave Webb

    If you had XP or later you could use TASKKILL. This on not NT though.

    I think you're going to have to download something to do this. I'd recommend pskill from Sysinternals.

    You can use this either with a process ID or just with a process name. For example:

    pskill notepad.exe
    

    Another option is KILL from the NT Resource Kit.

  • Tanguy

    To kill process with children (like apache), from Windows XP to Windows Seven :

    TASKKILL /T /F /PID 4520
    
  • beggs

    There are a couple of choices:

    KILL Command

    kill process name or id

    or

    kill -f process name or id

    AT Utility

    at time /interactive cmd /c kill -f process name or id

    And of course

    Reboot :-)