Keep Batch File Open to enter more commands

Typically the solution you will see to this question upon googling is to add “pause” to the end of your batch file.

This will keep the batch open, but it will not allow you to enter additional commands and after hitting a key will close the window immediately.

Alternatively, if you would like to keep the window open, such as creating a shortcut to a command line app, you can use cmd.exe /K.

MyApp.exe /?
cmd.exe /K cmd.exe

Place the above code snippet into batch file of your choosing, such as start menu folder, and upon launch it will not change into the directory and path where your command line app is located, execute it displaying it’s parameters (/? is app specific) and then run cmd.exe with \K option which allows the window to stay open per MSDN (see reference below).




About Ronnie Diaz

Ronnie Diaz is a software engineer and tech consultant. Ronnie started his career in front-end and back-end development for companies in ecommerce, service industries and remote education. This work transitioned from traditional desktop client-server applications through early cloud development. Software included human resource management and service technician workflows, online retail e-commerce and electronic ordering and fulfillment, IVR customer relational systems, and video streaming remote learning SCORM web applications. Hands on server experience and software performance optimization led to creation of a startup business focused on collocated data center services and continued experience with video streaming hardware and software. This led to a career in Amazon Prime Video where Ronnie is currently employed, building software and systems which stream live sports and events for millions of viewers around the world.

Posted on July 15, 2012, in Programming & Development and tagged , , , , , , , , , , , , , , , , , . Bookmark the permalink. 1 Comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: