I run batch files and they exit immediately. I dont want that to happen so that i can see my output. Can someone tell me how to make this happen ?
I use windows 7.
Solution-1:Create a VBScript file lets say Master. vbs and call your My. bat file within it. It'll run your batch file in invisible/hidden mode.
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
Add a pause statement to a batch file If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.
If you want the command prompt cmd widnow to stay open after executing the last command in batch file –you should write cmd /k command at the end of your batch file. This command will prevent the command prompt window from closing and you'll get the prompt back for giving more commands in the cmd window.
Adding pause is a good answer. Here are some other ways as well..
Rather than double-clicking on them to execute you can run from a command line:
If there is a lot of output and it scrolls off the screen you can direct the output to a text file instead like so:
somename.bat > output_filename.txt
Then you can open the 'output_filename.txt' file in any text editor to view/search all of the output. This is better than pause when there more output than what is available in the scrollback.
Put this on the very last line of the Batch:
cmd /k
Add the pause command at the end of your batch file. This waits for you to key something in.
(The nice thing is that if you're running the batch file from a non-interactive process, such as a automated build system or scheduled task, the pause is simply skipped.)
The help message for pause is:
C:\>help pause
Suspends processing of a batch program and displays the message
Press any key to continue . . .
If there is lots of output and you can't scroll far enough back, adjust the screen buffer height of the command window. This can be done via right-click on the c:\
icon go to properties
-> layout
:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With