Search code examples
windowscmdkeyboard-shortcutswindows-8.1taskkill

Can you set a keyboard shortcut for a Windows CMD command?


I'm running Windows 8.1 Pro and would like to know if it's possible to have a keyboard shortcut to run

taskkill /F /FI "STATUS eq NOT RESPONDING"

using CTRL + ALT + X

SIDE NOTE: I have currently have a work-around where I have a batch file (KillTask.bat) with the command and a desktop shortcut to KillTask.bat with the shortcut key set to CTRL + ALT + X.

Screenshot (Here's a link explaining the work-around)

Is there a more direct method of doing this by way of a keyboard shortcut without the use of desktop shortcuts and batch file?


Solution

  • You dont need the .bat. You can do the following:

    1. Create a shortcut and add the path:

    C:\Windows\System32\cmd.exe /c taskkill /F /FI "STATUS eq NOT RESPONDING"
    

    2. Got to the shortcut properties and put the shorctus key you want: CTRL + ALT + X.

    And that's all. The only file you need is the shortcut.

    The important thing here is that you execute cmd.exe with /c to specify the command you want to run.

    EDIT: Thanks to eryksun!

    Even better, we can just call taskkill directly:

    C:\Windows\System32\taskkill.exe /F /FI "STATUS eq NOT RESPONDING"
    

    But still, you need a shortcut file.