Nato51
Nato51

Reputation: 175

Batch force close window

How do I make a batch file close.

say if I had this code:

@echo off
goto loop
[exit command]
:loop

How would I make the batch file close its window. [exit command] would be the command that would make it exit.

Upvotes: 2

Views: 5763

Answers (2)

09stephenb
09stephenb

Reputation: 9796

Ok there are a fiew ways of doing this. The first one is this:

goto :eof

This sends the script to the end of the file so forth making it close.

EXIT

This is the most simple one just a simple exit.

For more information see this http://www.robvanderwoude.com/exit.php

Upvotes: 1

Joey
Joey

Reputation: 354466

If you really want to close the window, then use exit. However, this will affect a normal session as well, i.e. if you start cmd and run the batch file it will close your session.

If you merely want to exit the batch file (which will close the window if you started it via double-click), then you can use either one of

goto :eof
exit /b

Upvotes: 2

Related Questions