在Windows

时间:2016-07-10 23:02:20

标签: windows command-line command

我写了一个命令文件来备份我的数据。有5个这样的文件夹,我必须备份。我没有在系统启动时安排5个作业,而是编写了一个主命令文件,并在主站中调用其余的。请查看我的 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

问题是备份完全正常但仅适用于第一组,在备份第一组后,命令提示符不会移动到下一个命令但只是关闭

请纠正我出错的地方。三江源

1 个答案:

答案 0 :(得分:2)

使用CALL命令。这将启动一个单独的批次,第一个将继续。

例如:

  

CALL AntCommand.cmd>日志/%日期:〜-4,4- %%日期:〜-7,2 %%日期:〜-10,2%的.log   2 - ;&安培; 1