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
EXIT /B at the end of the batch file will stop execution of a batch file. use EXIT /B < exitcodes > at the end of the batch file to return custom return codes.
Using EXIT /B will stop execution of a batch file or subroutine and return control to the command processor or to the calling batch file or code immediately. EXIT /B is available in Windows 2000 and later versions' CMD.
To close or exit the Windows command line window, also referred to as command or cmd mode or DOS mode, type exit and press Enter . The exit command can also be placed in a batch file. Alternatively, if the window is not fullscreen, you can click the X close button in the top-right corner of the window.
Ctrl+C. One of the most universal methods of aborting a batch file, command, or another program while it's running is to press and hold Ctrl + C . This keyboard shortcut sends a SIGINT signal, which cancels or terminates the currently-running program and returns you to the command line.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With