Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need to write a batch file that will close after it is done. I know you can change the properties to close on exit but that does not help me. I need to close the batch file at the last line of commands. I tried "exit" but that did not work.
Thanks

I've never seen a batch file that didn't close when it was finished running, unless you have some type of halt, pause or loop command in it.

It has been a while for this so bare with me, but i believe that if you use a batch file to start an exe or another batch file, you have to use the "call" command, so that after the command is ran it will return to the batch file and finish, i cant guarentee this will work but give it a try

geo,
You're absolutely correct that this will return you to the batch file, but that isn't what the question seemed to be. A batch file automatically closes when it finishes running.

Tom Lavedas says:
If it can be assures that the ANSI.SYS driver is not loaded and/or that
the background color of the window is black, then just add these two
commands at the end of the procedure ...cls
@exitIf the desire is to be iron clad, even when ANSI.SYS is loaded, use ...
(for command all on one line)for %%v in ("prompt $e[m" "echo on" cls) do %%v
@exit
:::::::::
The above is for Win95-98

what a bloody load of long winded answers just right click 0n batch file, click properties, click the program tab then click "close on exit" then make last line in bat file exit then run bat file from shortcut
simple!

Hey bossman, if you had read the problem description, Steven does state that he tried the "close on exit" button and it didnt work for him, so lets just stick with bloody solutions instead of idiotic comments about what other people suggest trying.

Steven I don't know it you found a solution yet, but I has a simular situation. I've come up with two solutions. Put "C:\command.com /c" on the first line before the rest of your command. If that doesn't work, I had to go to the properties of the batch file, and I pointed to the new ".pif" created by the batch properties when I check close on exit. I know you don't want to use the properties option, but the ".pif" may be another solution. Don't forget to edit the "CMD LINE" on the PROGRAM tab to point to where ever you move the .bat and .pif.

![]() |
![]() |
![]() |

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