我正在尝试运行一个批处理文件,测试 4 个不同的文件,然后根据存在的正确文件运行正确的命令

我正在尝试运行一个批处理文件,测试 4 个不同的文件,然后根据存在的正确文件运行正确的命令
:: 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

相关内容