I\'m running a batch file that has these two lines:
start C:\\Users\\Yiwei\\Downloads\\putty.exe -load \"MathCS-labMachine1\"
\"C:\\Program Files (x86)\\Xmi
You could try the somewhat dangerous: taskkill /IM cmd.exe
..dangerous bcz that will kill the cmd that is open and any cmd's opened before it.
Or add a verification to confirm that you had the right cmd.exe and then kill it via PID, such as this:
set loc=%time%%random%
title=%loc%
for /f "tokens=2 delims= " %%A in ('tasklist /v ^| findstr /i "%loc%"') do (taskkill /PID %%A)
Substitute (pslist &&A)
or (tasklist /FI "PID eq %%A")
for the (taskkill /PID %%A)
if you want to check it first (and maybe have pstools installed).
You normally end a batch file with a line that just says exit
. If you want to make sure the file has run and the DOS window closes after 2 seconds, you can add the lines:
timeout 2 >nul
exit
But the exit
command will not work if your batch file opens another window, because while ever the second window is open the old DOS window will also be displayed.
SOLUTION: For example there's a great little free program called BgInfo which will display all the info about your computer. Assuming it's in a directory called C:\BgInfo
, to run it from a batch file with the /popup
switch and to close the DOS window while it still runs, use:
start "" "C:\BgInfo\BgInfo.exe" /popup
exit