Showing posts with label bat. Show all posts
Showing posts with label bat. Show all posts

Friday, November 27, 2015

MSDOS applications run with pause on exit

I have a shortcut to a .BAT file (or any kind of DOS application). I need after its execution, DOS window not to close until i read the output of the program(s).

Adding a line with pause in the end of file is not an option (my file stays in VCS).

Solution: You could change the command of shortcut from this:

c:\path\shortcut.bat

to this:

c:\path\shortcut.bat & pause

You will get an message "Press any key to continue" and you will read the output of the program.

Friday, August 12, 2011

MS DOS batch tips

So, by way of tribute to the dying art of the DOS Batch file, I present my top ten batch file tricks:

1 Use PUSHD / POPD to change directories
Read Scott Hanselman's writeup on PUSHD. The basic idea is that it keeps a stack, so at the simplest level you can do something like this:

PUSHD "C:\Working Directory\" ::DO SOME WORK POPD

That allows you to call the batch file from any directory and return to the original directory when you're done. The cool thing is that PUSHD can be nested, so you can move all over the place within your scripts and just POPD your way out when you're done.