Taskkill /PID not working in GitBash - bash

I'm trying to kill a process on GitBash on Windows10 using the taskkill command. However, I get the following error:
$ taskkill /pid 13588
ERROR: Invalid argument/option - 'C:/Program Files/Git/pid'.
Type "TASKKILL /?" for usage.
it works fine on cmd. Can anyone help?

You have to use double slashes in this case:
taskkill //PID 13588
This is documented here: http://www.mingw.org/wiki/Posix_path_conversion
Look at the examples on this page, especially the //foobar example.

Use TSKILL processid
Example:
TSKILL 1234

To fix this I need to kill another additional program:
taskkill //F //IM "git-bash.exe"
taskkill //F //IM "bash.exe"

To delete the child processes as well, use the "/T" argument.
taskkill //PID 13588 //T
use double slashes before argument.

This is what actually worked for me:
taskkill /F /IM mintty.exe

What worked for me:
Run Git Bash as administrator
taskkill -f -fi "services eq msiserver"

Related

TASKKILL specific Python script

I have a working TASKKILL command that kills python.exe using Process Name
I'd like to narrow the scope of the command to kill a specific process (myScript.py) but can't use ProcessID as it changes with every run.
Is there a way I can add detail from the Command Line which knows the python script's name?
Current Command:
Taskkill /IM python.exe /F >nul 2>&1
if errorlevel 1 (echo PYTHON.exe NOT FOUND) else (echo PYTHON.exe KILLED)
You might be able to kill it based on your Python script's memory usage. In my case, the Python script is running a GUI, so the size gives it away.
taskkill /f /fi "IMAGENAME eq python.exe" /fi "MEMUSAGE gt 130000"
This reads as, forcefully kill the task (taskkill /f) identified by (/fi) the Python executable (IMAGENAME eq python.exe) which is using more than 130,000KB (MEMUSAGE gt 130000)1.
1 See taskkill /? for builtin help.
N.B. You might find this SO post helpful: Find Windows PID of a python script with Windows Command Prompt. Unfortunately, for me, It Doesn't Work™ but maybe you will have better luck.

How to kill a task in batch?

I am having problems with the taskkill in batch, I am trying to kill a vbscript that is in sleep for an x amount of seconds.
So basically I want to kill this task:
http://i.imgur.com/nNVf1Fh.png
But I somehow seem to get it wrong, I have no clue what part of the task I have to write in the taskkill x
Thank you in advance!
This will kill it without knowing the pid, however it will kill all instances of wscript.exe.
TASKKILL /F /IM wscript.exe
From the task manager top menu, select to show the Process ID for this running process.
Then on command prompt,
taskkill /pid 1234
Where 1234 id the Process ID you want to kill.
VBScripts do have a timeout parameter - see cscript /?.
taskkill /im wscript.exe /im cscript.exe /f
will kill all running vbscripts.
If you want to be particular how do you tell the running scripts apart.

Batch script to close all open Command Prompt windows

I have a .cmd file which I call to open multiple instances of Command Prompt via:
launcher.cmd -fs
launcher.cmd -tds
launcher.cmd -fsd
Each command open a new command prompt.
So what I want to do is create a batch file to automatically close all the opened Command Prompt instead of manually doing it.
Be carefull: you might kill more processes than you want:
taskkill /IM cmd.exe
You can add extra filters:
taskkill /IM cmd.exe /FI "WINDOWTITLE eq launcher*"
use
tasklist /FI "imagename eq cmd.exe " /V
to get a glimpse of what cmd.exe processes will be taskkill-ed
You could add the /F parameter to force the process to close but I would only use that if the process doesn't respond to a normal request.
Just a little note why accepted answer from Rene may not work. I was starting my apps from cmd file like
start "" my.exe -my -args
where my.exe was a console app and it was looking like cmd window I wanted to kill, but process name was not cmd.exe (!) and I had to use command like
taskkill /IM my.exe
So in some cases it worth to check the real process name, for example in the windows task manager.
TASKKILL /F /IM cmd.exe /T
good solution

How to modify return code in Visual Studio Build events

Is it possible to modify the return code (I think it is also called errorlevel) of a command submitted in the Build events of Visual Studio?
I am running the command taskkill /F /IM MyApp.vshost.exe and I would like this command to return 0 when it is in fact returning 128.
Redirect all output to a temp file and exit with code 0, in a batch file. This will effectively ignore any errors from taskkill:
killit.bat:
taskkill /F /IM MyApp.vshost.exe > %temp%\out.txt 2>&1
exit /B 0
Now invoke killit.bat in the build event.
Update After hege posted his answer I figured just pasting the code from the batch file into the build event should work as well, since to my understanding build events in VC are always executed on the command line anyway. And indeed
taskkill /F /IM MyApp.vshost.exe > %temp%\out.txt 2>&1 || exit /B 0
as a build event works as well. The redirection is still required though.
Try taskkill /F /IM MyApp.vshost.exe || exit /b 0 .
As seen here in the comment of the accepted answer:
Solve "The command "taskkill /F /IM MyApp.vshost.exe" exited with code 128" error
taskkill /F /IM MyApp.vshost.exe /fi "pid gt 0"
taskkill with filter returns no error.

Killing a process with taskkill /F returning code 0

I need to kill a windows process (java.exe). I'm currently using:
taskkill.exe /F /IM java.exe
I need to use the /F option since is a critical process,but in this way I get a return code 1 instead I need a return code 0 (returned when I don't use /F for killing other not critical processes)
how could I fix this problem?
Many thanks
You can try with :
TASKKILL /F /IM "notepad.exe"
You can know more here. Visit this blog too.
Why don't you use PowerShell?
Stop-Process -Name java.exe
From the old command prompt:
powershell -Command "Stop-Process -Name java.exe"
I am using following command on Windows Server 2008R2
Taskkill /IM B2B_Crawler_V2.exe /F
Refer Taskkill and Killing a process in Batch and reporting on success
Execute this in CMD
Get the list of open processes
netstat -a -o -n
And then kill the process on that port with the following command
taskkill /F /PID <pid>

Resources