Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 594
zodac Avatar asked May 12 '15 15:05

zodac


People also ask

How do I kill a session in Git bash?

ctrl+c in gitbash on windows terminal kills ssh remote sessions #12431.

Does Taskkill require admin?

Taskkill is a program that needs administrative privileges to kill a task. If you start command prompt as admin and run the same command, it will succesfully kill the task.

How do I control C in Git bash?

Copying and Pasting in Git BashCtrl+C interrupts the currently running command, while Ctrl+V tells the terminal to treat the next typed character as a literal, (e.g. to literally add a keyboard combo such as Ctrl+C ).

What is the command to Taskkill?

If you want to explore what's available, type taskkill /? then hit Enter. This will reveal some powerful options for using Task Kill. For example, if you want to kill a group of programs, type: TASKKILL /PID 1230 /PID 1241 /PID 1253 /T.


1 Answers

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.

like image 114
Godsmith Avatar answered Oct 13 '22 00:10

Godsmith