I have a batch that used to kill VLC.
echo
rem choice /c YN /n /d Y /t 120
taskkill /im vlc.exe
Now when it runs, VLC stays open, even though the CMD reports the taskkill command was successfully sent.
Any ideas? Perhaps a VLC (currently 2.1.5) update make it no longer work.
Is taskkill /im vlc.exe /f or taskkill /im vlc.exe /t /f working for you? Had the same problem with explorer.exe a while ago...
Related
I wanted to close opened app by running a batchfile code . My current code does not work and just freezes all black.
Code
#echo off
echo closing all programs...
taskkill /f /t /im explorer.exe
explorer.exe
I think taskkill /f /im explorer.exe should work oh and you should do pause or pause >nul at the end of the script else your program won't start also explorer.exe at the end of your script is not needed.
I have 2 unwanted processes running: foo.exe and bar.exe, and both have child processes started by them.
I want to use taskkill to terminate all these processes (foo.exe, bar.exe and all child ones). Do I need to use \t parameter only once or do I need to use it multiple times? I.e., which version is correct:
a) taskkill /f /im "foo.exe" /im "bar.exe" /t
b) taskkill /f /im "foo.exe" /t /im "bar.exe" /t
?
Well, a for loop will be more meaningful as you can add/remove imagenames as you please:
Using batch file:
#echo off
for %%i in (foo.exe bar.exe) do taskkill /f /im "%%i" /t
From cmdline:
for %i in (foo.exe bar.exe) do taskkill /f /im "%i" /t
I've tried restarting a program every few minutes with a batch file which looks like the following. However it only opens the .exe a lot of times which causes them to crash. Anyone knows why this problem occurs?
#echo off
:loop
start "programm" "D:\Downloads\programm.exe"
timeout /t 1200 >null
taskkill /f /im "programm" >null
timeout /t 7 >null
goto loop
I hate a short answer, but it's an easy and quick fix. null is nothing, use nul as it's almost certainly skipping the invalid output name.
So the code:
#echo off
:loop
start "programm" "D:\Downloads\programm.exe"
timeout /t 1200 >nul
taskkill /f /im "programm" >nul
timeout /t 7 >nul
goto :loop
taskkill /f /im "programm" >null
Remove the >null and look why it doesn't kill the program.
I am running a command in command prompt and I want to kill it after 15 minutes. I don't care if it is completed or not. I don't want to have any human interaction to kill the running command such as someone has to press CTRL+C to kill it.
Is there a way to do it.
Please note I don;t want to use any third party tools or scripts.
start forfiles /s
timeout /t 5
Taskkill /im forfiles.exe /f
is one way.
Did you mean something like that ?
#echo off
Tracert www.google.com
timeout /t 900 /nobreak >NUL
Taskkill /im cmd.exe /f
Edit : based on the blueray's comment :
how can I put this command in a single line to use in CMD?
Tracert www.google.com & timeout /t 900 /nobreak >NUL & Taskkill /im cmd.exe /f
May be this could help
start your-command-here
ping 127.0.0.1 -n 120 > NUL
taskkill /im cmd.exe /f
Explanation:
start: this command starts executing your command
ping: it pings your local machine(ip : 127.0.0.1) for 120 sec and >NUL redirects the output to nowhere else the output of ping command will be displayed on the cmd screen
taskkill: it is used to kill any task
/im: image name of the process to be terminated. if the command is running on cmd then cmd.exe or any program that you need to kill.
Hope it helps.
Try this, works well for me:
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
#echo off
set _time=0
set _timeout=30
start myprocess.exe
:waitforprocess
set /A _time=_time+1
IF !_time! GTR !_timeout! goto TimedOut
rem TaskList will return the task list of the image as specific
rem or it will return INFO: No tasks are running.... so look for
rem the INFO statement using FindStr. FindStr will return a errorlevel
rem of 0 if it found the string and a 1 if it did not, so use that
rem to work out next steps.
rem -------------------------------------------------------------------
tasklist /NH /FI "IMAGENAME EQ myprocess.exe" | findstr INFO
rem ERRORLEVEL 1 = Did not find the string, so try again.
IF ERRORLEVEL 1 (
timeout /T 1 /NOBREAK > nul
goto :waitforprocess
)
GOTO DONE
:TimedOut
ECHO We timedout so will kill the process
taskkill /FI "IMAGENAME EQ myprocess.exe" /T /F
:Done
echo finished
I want a batch file that will kill all of chrome.exe process. I came across with this sample:
taskkill /im chrome.exe
which kill only the first process of chrome.exe that it find. how can I loop it?
You can use this:
taskkill /F /IM <processname.exe> /T
taskkill /F /IM Chrome.exe /T