We help IT Professionals succeed at work.

how to auto close DOS window after a batch of command file has completed running?

brgdotnet
brgdotnet asked
on
Medium Priority
127 Views
Last Modified: 2019-08-19
In the DOS command window, after my dos command or batch file has completed it's run, I would like for the dos window to close. Does anyone know if there is a command which will close the dos window after the command file has completed it's run?  You see I am not allowed to change the command file "mergeStrayFiles.cmd", so I cannot place a close dos window command inside of my .cmd file. So somehow dos needs to close the dos windows once the command file has completed running.




>mergeStrayFiles.cmd
Comment
Watch Question

Test your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
You should be able to use the EXIT command to do that.But it sounds like you may not be able to do that?

Is there any output displayed by the CMD script you need to run?  If not why not just launch it from Explorer or the Run dialog?

If you need to run it from a command window to see output, then you could try something like:

mergeStrayFiles.cmd & pause & exit


»bp
CERTIFIED EXPERT

Commented:
This is odd...If you execute a cmd file. it will close automatically after everything is DONE in the CMD File. So if it does not close, something is still ongoing.
If you enter dos first, then execute the cmd file you cannot close it automatically

What you can do is, create a second CMD file

ExecuteMyCmd.cmd
start mergeStrayFiles.cmd 
exit

Open in new window


and execute that one in the commandline. Then the commandline will close itself afterwards.

But still. very odd case...
JohnBusiness Consultant (Owner)
Most Valuable Expert 2012
Expert of the Year 2018

Commented:
The above is a good solution

Also ask the owner of the command file to adjust the lines to end normally and the window should close.  I use batch files quite a bit still