HOW to EXIT using "start" in batch files of MSDOS
15,406
Solution 1
You need to escape && so it becomes part of the command executed by start and not the parent batch file.
start copy a.txt h: ^&^& exit
To close the new console even if there are errors you can do:
start "" "%comspec%" /c copy a.txt h:
Solution 2
You can use start
to start a new cmd window and close it once the command has been run like this:
start cmd /c copy a.txt h:

Author by
Admin
Updated on June 04, 2022Comments
-
Admin about 8 hours
I want to copy some files into diffent USB disks, and want to use START to open several consoles as follows:
start copy a.txt h: start copy a.txt i: start copy a.txt j:
But everytime I run the batch file, there are 3 consoles without exiting. How can I realize this EXIT function WITHOUT using 3 batch files and "call" commands as:
copy.bat:
call a.bat call b.bat call c.bat exit
and three called batch files as:
a.bat:
start copy a.txt h: exit
b.bat:
start copy a.txt i: exit
c.bat:
start copy a.txt j: exit
I already tried this, but it DOES NOT work:
start copy a.txt h: && exit start copy a.txt i: && exit start copy a.txt j: && exit