![我正在尝试运行一个批处理文件,测试 4 个不同的文件,然后根据存在的正确文件运行正确的命令](https://linux22.com/image/1403200/%E6%88%91%E6%AD%A3%E5%9C%A8%E5%B0%9D%E8%AF%95%E8%BF%90%E8%A1%8C%E4%B8%80%E4%B8%AA%E6%89%B9%E5%A4%84%E7%90%86%E6%96%87%E4%BB%B6%EF%BC%8C%E6%B5%8B%E8%AF%95%204%20%E4%B8%AA%E4%B8%8D%E5%90%8C%E7%9A%84%E6%96%87%E4%BB%B6%EF%BC%8C%E7%84%B6%E5%90%8E%E6%A0%B9%E6%8D%AE%E5%AD%98%E5%9C%A8%E7%9A%84%E6%AD%A3%E7%A1%AE%E6%96%87%E4%BB%B6%E8%BF%90%E8%A1%8C%E6%AD%A3%E7%A1%AE%E7%9A%84%E5%91%BD%E4%BB%A4.png)
:: batch file to run backup
@echo off
setlocal
set backup1=="F:\my backups\Disk_1_DataBAckup"
set backup2== "F:\My backups\2_backup_data_to_disk2"
set backup3=="G:\my backups\3_backup_data_to_disk3"
set backup4=="F:\my backups\data_backup_for_disk4"
if exist %backup1% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:44AD8A39-ADEF-44E6-8CD9-310C8B992E61
if exist %backup2% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:7828307B-E0AB-45A5-A7BD-EF2D522A5C3F
if exist %backup3% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:B81797C0-B4F0-457B-8644-767584C4B228
if exist %backup4% "C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:E2393AB1-A4A8-4A51-958D-FCEE28715BE0
endlocal
由于某种原因,这不起作用,而且我对批处理文件完全不熟悉。我正在运行 Windows 7(如果这很重要的话)我每天都会更换外部备份磁盘,因此我需要批处理文件来检查连接的驱动器,然后运行适当的备份。
答案1
我只做了大约一周,但如果我要这样做,我会尝试这样做
@echo off
IF EXIST "F:\My backups\Disk_1_DataBAckup" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:44AD8A39- ADEF-44E6-8CD9-310C8B992E61
) ELSE (
ECHO No backup 1
)
IF EXIST "F:\My backups\2_backup_data_to_disk2" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:7828307B- E0AB-45A5-A7BD-EF2D522A5C3F
) ELSE (
ECHO No backup 2
)
IF EXIST "G:\my backups\3_backup_data_to_disk3" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:B81797C0- B4F0-457B-8644-767584C4B228
) ELSE (
ECHO No backup 3
)
IF EXIST "F:\my backups\data_backup_for_disk4" (
"C:\Program Files (x86)\Acronis\TrueImageHome\TrueImageLauncher.exe" /script:E2393AB1- A4A8-4A51-958D-FCEE28715BE0
) ELSE (
ECHO No backup 4
)
pause
EXIT