How do you stop batch files from closing?

  • Thread starter Thread starter Mickey Segal
  • Start date Start date
M

Mickey Segal

After upgrading to Windows XP, I find that the DOS batch files (launched by
clicking on the *.bat file) close automatically. I would like the DOS
window to stay open so I could see the results of the commands. I tried
fiddling with the right-click properties of the *.bat file but I don't see
any options that help. I think I have turned on all file viewing so I don't
think I am missing a companion file as was used in Windows 98.

All the Usenet postings I find on this subject refer to the opposite
problem, with complaints that the window does close automatically. I am
trying to achieve the opposite: allowing the window to stay open.

It seems like there should be a simple answer to this.
 
Edit the batch files by adding "pause" to the end of it. Or just before the
exit command if there is one. Then the DOS windows will stay open till you
press a key.
 
You can add a "pause" command at the end of the batch. In this case, it
will wait for user input before it closes. Or, if you'd rather the batch
wait a specific amount of time before it closes, you could add something
like "ping -n <number of seconds> 127.0.0.1 >NUL" at the end of the batch.
Just put a whole number in place of the <number of seconds> string.

--
Tony Talmage
Web Developer
Graphic Education Corporation
http://www.graphiced.com
(888) 354-6600
 
Yor Suiris said:
Edit the batch files by adding "pause" to the end of it. Or just before the
exit command if there is one. Then the DOS windows will stay open till you
press a key.

Thanks. I guess there is no backward-compatibility problem in adding this
to all my batch files.
 
Greetings --

Run the batch file from within the command prompt window.

Bruce Chambers

--
Help us help you:



You can have peace. Or you can have freedom. Don't ever count on
having both at once. -- RAH
 
Stuart said:
Run your batch files from the cmd prompt - problem solved.

I added the pause commands. There were just 10 files and modifying them was
easier than having to bother with the command line.
 
Mickey said:
Thanks. I guess there is no backward-compatibility problem in adding this
to all my batch files.

Pretty easy and fast to do this with a bat file.

You could write a bat file which appends as a "last line" to each of the
bat files the "pause" command (using the copy command with the "+"
command line option for appending files).

This only works, of course, if this would make programming logic sense
for the end of each program, but from the information you provide this
seems a reasonable assumption.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top