简体   繁体   中英

Running same command line more than once in windows

I have written a command file to take backup of my data. There are 5 such folders where I have to take backup. Instead of scheduling 5 jobs at system start up, I have written a master command file and calling rest of them in the master. Please look into my below master.cmd

@echo OFF

:: backup1
echo Data Backup in Progress for 1
cd C:/Users/backups/1
AntCommand.cmd > logs/%date:~-4,4%%date:~-7,2%%date:~-10,2%.log 2>&1
echo Backup Complete for 1

::backup2
echo Data Backup in Progress for 2
cd C:/Users/backups/2
AntCommand.cmd > logs/%date:~-4,4%%date:~-7,2%%date:~-10,2%.log 2>&1
echo Backup Complete for 2

::backup3
echo Data Backup in Progress for 3
cd C:/Users/backups/3
AntCommand.cmd > logs/%date:~-4,4%%date:~-7,2%%date:~-10,2%.log 2>&1
echo Backup Complete for 3

::backup4
echo Data Backup in Progress for 4
cd C:/Users/backups/4
AntCommand.cmd > logs/%date:~-4,4%%date:~-7,2%%date:~-10,2%.log 2>&1
echo Backup Complete for 4

::backup5
echo Data Backup in Progress for 5
cd C:/Users/backups/5
AntCommand.cmd > logs/%date:~-4,4%%date:~-7,2%%date:~-10,2%.log 2>&1
echo Backup Complete for 5

Issue is backup is perfectly working but only for the first set, after backing up the 1st set, command prompt does not move to the next command but just closes

Please correct me where I am going wrong. Thankyou

Use the CALL command. This will launch a separate batch, and the first will continue afterwards.

For example:

CALL AntCommand.cmd > logs/%date:~-4,4%%date:~-7,2%%date:~-10,2%.log 2>&1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM