Like UNIX ampersand: launch documents and close batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
d360991
Posts: 8
Joined: 18 Mar 2012 13:12

Like UNIX ampersand: launch documents and close batch file

#1 Post by d360991 » 18 Mar 2012 13:16

I'd like to open a bunch of documents (.txt or .docx or .ppt) using a batch file. Therefore, I have a batch file with the following structure:

"filename1.txt" &
"filename2.txt" &

If my text editor is open, this batch file will open the .txt files in the text editor and the batch file (DOS console) will close. If the text editor is not open, the batch file launches text editor, opens filename1.txt. Only after I close the text editor, the batch file (DOS console) will open filename2.txt. The batch file (DOS console) will close only after all the documents it opened are closed.

How do I prevent this? If I have a bunch of commands in a batch file, the batch file should launch the necessary applications and the documents and close, without waiting for the user to close the documents / application software.

Thanks for your time.
-Nina

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Like UNIX ampersand: launch documents and close batch fi

#2 Post by aGerman » 18 Mar 2012 13:44

The command lines of a batch file are executed synchronously by default. Use the START command to let it work asynchronously in this case.

Code: Select all

start "" "filename1.txt"
start "" "filename2.txt"

Regards
aGerman

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Like UNIX ampersand: launch documents and close batch fi

#3 Post by foxidrive » 18 Mar 2012 20:52

Just adding here that I think some text editors can take multiple filenames/filespec on the command line, and open each file in a tab.

Post Reply