Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have encountered a bizarre problem which I've been completely unable to fathom:
I have a small batch file which I've written to perform a certain job on the hard drive. Now it is my desire to have this batch file terminate itself when the job is finished, so, naturally, I conlcuded my text with the command 'exit'.
When the file is run, however, the task is successfully completed, but the DOS window just hangs around on the screen, waiting for me to click the X box in the upper right to close it.
I wrote the following batch this morning:
echo off
cls
echo.
echo Test File
echo.
exitThe same result. The task (in this case displaying text) ran fine, but the program just stopped when it had finished instead of automatically exiting.
Anyone have any ideas???
PS: Please answer by email only (smokingmirror@hotmail.com), as it's not always possible for me to get on these forums very much. Thanks.

Right click the batch file and under properties, program, choose 'close on exit'
Sorry, if you can manage to check your email, you can find time to check your post - this is an open forum.

Maybe I'm missing something here, but Gorx, how does the clear screen command exit a dos window? (Hey jboy!)

In this case the exit is not needed. Once the batch file completes its final command, then the program is finished and it will automatically exit. The exit command would be used if you need to quit the program prior to the final command. The real problem here is to close the DOS window which is done by the method that jboy described.

well there is exit and then there's close the window.
my guess would be because it's still has text in the window the exit command isn't closing it just not making it active anymore.
when you use the close on exit setting it will create a PIF file

I have several batch files all of which have cls as the last line. The "close window on exit" is not ticked. They all close fine.
Derek

I just did a test. Created a bat file with CLS as the last command. The window did not close.
Win98SE system.
AMD CPU

I just did a test and it works fine
windows 98se-----------------
echo off
cls
echo.
echo testing 1..2..3
echo.
echo.
pausecls
-----------------the only thing I can think of is if you running something else thru the bat file.
such as using the Call or the Start commands or just running a path to another batch file or app.
each one while similar have slite differences.I can't tell you why it's not working on your system but I can tell you it does work.

Ran your file Gorx, and got;
testing 1..2..3
Press any key to continue . . .Didn't close the dos window.
???????

One possible reason why cls doesn't clear a batch file (not checked) is if there is a Return after it. There should always be a Return at the end of a .reg file but never after a .bat file.

With or without a Return at the end it worked on my pc :~/
Windows 98 [Version 4.10.2222]Greetz,
The Count

The Count
Thanks for follow-up & info.
I recall there was some problem or other that a Return at the end of a batch file once caused me, so I never use it.
Sorry, I've forgotten the exact circumstances but you've obviously proved that it's not this particular situation.
Derek

![]() |
Opening Task Manager?
|
NVidia GForce 2 Probs
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |