Search code examples
windowsgit-bashtaskkill

Trouble running TASKKILL from GitBash


I'm trying to create a function in my .bashrc to run in gitbash. The command I'm trying to run is:

cmd '/C TASKKILL /fi "WINDOWTITLE eq  Windows Task Manager"'

I'll be changing the "Windows Task Manager" bit, but just to show what I'm trying. The command (TASKKILL /fi "WINDOWTITLE eq Windows Task Manager") works fine when I run it through Windows cmd, but when I run from gitbash, I get this error message:

ERROR: Invalid argument/option - 'eq'.
Type "TASKKILL /?" for usage.

As I said, it works fine in cmd, so I'm thinking it's something to do with the quotation marks. I've also tried the following, which also fails:

cmd "/C TASKKILL /fi \"WINDOWTITLE eq  Windows Task Manager\""

I could put the command in a .bat file and run that (cmd "/C pathtofile/script.bat") and that works, but I'd prefer to run it straight from the .bashrc, if possible.


Solution

  • cmd "/C TASKKILL /fi "WINDOWTITLE eq  Windows Task Manager""
    

    It seems like it shouldn't work due to how the quotation marks are nested, but it does.