I have two batch files, one of them executes another, i.e.
I\'ve created a shortcut of the firs
put at the end it will reopen your console
start cmd
In the last line of the batch file that you want to keep open put a
pause >nul
If that is really all the batch file is doing, remove the cmd /K
and add PAUSE
.
start /B /LOW /WAIT make package
PAUSE
Then, just point your shortcut to "My Batch File.bat"
...no need to run it with CMD /K
.
Ah, some new info...you're trying to do it from a pinned shortcut on the taskbar.
I found this, Adding Batch Files to Windows 7 Taskbar like the Vista/XP Quick Launch, with the relevant part below.
- First, pin a shortcut for
CMD.EXE
to the taskbar by hitting the start button, then type "cmd" in the search box, right-click the result and chose "Pin to Taskbar".- Right-click the shortcut on the taskbar.
- You will see a list that includes "Command Prompt" and "Unpin this program from the taskbar".
- Right-click the icon for
CMD.EXE
and selectProperties
.- In the box for Target, go to the end of
"%SystemRoot%\system32\cmd.exe"
and type" /C "
and the path and name of the batch file.
For your purposes, you can either:
Use /C
and put a PAUSE
at the end of your batch file.
OR
/K
and remove the PAUSE
from your batch file.At here:
cmd.exe /k "<SomePath>\<My Batch File>.bat" & pause
Take a look what are you doing:
How to resolve it? well,using the correct syntax, enclosing the argument for the new CMD instance:
cmd.exe /k ""<SomePath>\<My Batch File>.bat" & pause"
rem Just use "pause" at the end of the batch file.
...
......
.......
pause
You can just put a pause command in the last line of your batch file:
@echo off
echo Hey, I'm just doing some work for you.
pause
Will give you something like this as output:
Hey, I'm just doing some work for you.
Press any key to continue ...
Note: Using the @echo prevents to output the command before the output is printed.