Search code examples
batch-filewindows-7batch-processing

How to close the command line window after running a batch file?


I've got a batch file. After it finished running, i.e. all command lines have been executed, the cmd.exe window stays open. However, I'd like to have it closed right after the batch file finishes its job.

So far I've tried using the exit command within the batch file to close the cmd window (I also have a shortcut on the desktop) but it doesn't seem to work:

tncserver.exe C:\Work -p4 -b57600 -r -cFE -tTNC426B
exit

Solution

  • It should close automatically, if it doesn't it means that it is stuck on the first command.

    In your example it should close either automatically (without the exit) or explicitly with the exit. I think the issue is with the first command you are running not returning properly.

    As a work around you can try using

    start "" tncserver.exe C:\Work -p4 -b57600 -r -cFE -tTNC426B