How to close the window of a batch (BAT) file immediately after execution


The window opened by a batch file remains open for as long as all applications and documents opened by that batch file remain open! Do you wish a batch window would close immediately after execution?

To have the window of the batch file close immediately, you need to use the start command in front of file names.

For example, let’s say we write a batch file to open the TLG application and a Word document:

"C:\Program Files\TLGWork\tlg32.exe"
"C:\My Documents\practice.doc"

This batch file waits for tlg.exe and practice.doc to close before it closes its window. Now, if we write

start "" "C:\Program Files\TLGWork\tlg32.exe"
start "" "C:\My Documents\practice.doc"

our batch file closes right after the TLG application opens and practice.doc is loaded in MS Word. Enjoy!

Report a problem on this page / Make a Request
Get The Power & Follow! don't miss   : :   Sleeper   Favorite Launcher   Savy   Gadgetarian
Fling   Power Copy   Windows Rule   SearchALL Gadget   Amazon Gadget

4 Responses

  1. Daniel says:

    Thanks for the good information. I was waiting for some time for this.
    Br

  2. tutumannyaque says:

    Thanks ! Worked perfectly ! Useful tips like this are pretty damn rare.

  3. Reidy105 says:

    Thank you just what I’ve been looking for

  4. verkkopeli says:

    Excellent piece of advice, thank you very much!

    After a bit of fiddling I discovered that the ‘start’ command enables executing a program and then opening a file within that program, after which the DOS prompt will still disappear. Here’s an example that opens “notes.txt” within notepad and exits:

    @echo off
    start notepad "notes.txt"