QUOTE (Dobby @ Jan 18 2005, 03:56 PM)
Err... nil, CLS stands for clear screen. It has nothing to do with exiting the batch file.
Pedantically, you're right. CLS has nothing to do with exiting a batch file. And neither does EXIT (which is designed to end a command-line shell, not batch processes). None of which helps explain why your presumptions are flawed.

The issue being refered to was the closing of the console window which remains open, in some cases, after a batch process ends. That issue is caused by the use of
any command which sends output to the console device and the solution to the problem
does involve the use of CLS (and not EXIT - see below). Your disbelief is understandable (it certainly isn't a logical solution) but I can tell you it sure does work.
You can test it for yourself by creating a batch file with the following lines on the desktop and double-clicking the file:
CODE
@echo off
pause
When the batch process ends the console window remains open (on all Win9x systems that I've tested it on at least) and needs to be closed manually. Now edit the file to read as follows:
CODE
@echo off
pause>nul
As no output is sent to the console (PAUSE's output is redirected to the "nul" device) you should find that the window will close automagically when the batch file ends (which won't happen in this case if you forget to press any key...).
The how and why is beyond me but getting the window to auto-close after one or more commands have output to the console seems to require the use of CLS, eg:
CODE
@echo off
pause
cls
See, I told ya CLS stands for CLose Sceen!

The CLS needn't be at the end of the file by the way, just ensure no command sends output to the console after the CLS is issued. The following example batch file will also auto-close:
CODE
@echo off
pause
cls
::
dir>nul
::
Note that the use of EXIT in a batch file appears to be
absolutely unnecessary for the purpose of auto-closing an orphan console window (and needn't be prepended with a '@' if it is used within a batch file as the command produces no output).
Again, the intended purpose of EXIT is to close the commandline shell it is issued from, and while it
can be used to "exit" a batch file it's a rather crude (and arrogant) way of handling it (on someone else's system). Batch file execution ends when the command line interpreter reaches the end of the file so for a far more user friendly approach (and to stop us DOSbox users chucking cold pricklies at you) try using GOTO instead:
CODE
@echo off
...
goto:end
...
:end
cls
Anyhow I would be interested in hearing of any case where the CLS/EXIT combination (rather than CLS alone) is actually required.
Cheers.