问题描述
我正在使用从批处理文件运行的卸载字符串来卸载软件。它会成功卸载软件并删除存储在C:Test\Data
中的数据文件。
我要在卸载后将数据文件复制回相同的位置,但不复制回Data
文件夹。
我不确定在这里我做错了什么。
if exist "C:\Test\Data" (
mkdir C:\TempMPC
start /wait /b xcopy C:\Test\Data C:\TempMPC /S /I /Y /R
rem wait for a moment
timeout /t 2 /nobreak > nul
)
"C:\Program Files (x86)\InstallShield Installation @R_856_4045@ion\{2EA86967-B3D3-4B2E-9DE9-28A595AF2E2E}\setup.exe" -runfromtemp -l0x0409 -removeonly /s /f1
timeout /t 5 /nobreak > nul
// THis is not working but if I delete the above command it works
if exist "C:\TempMPC" (
if not exist "C:\Test\Data" (
mkdir C:\Test\Data
)
timeout /t 2 /nobreak > nul
start /wait /b xcopy /S /I /Y /R C:\TempMPC C:\Test\Data
rem wait for a moment
timeout /t 1 /nobreak > nul
)
感谢Gerhard的投入,我以这种方式尝试过
@echo off
if not exist exist "C:\Test\Data" goto :eof
mkdir "C:\TempMPC">nul 2>&1
robocopy "C:\Test\Data" "C:\TempMPC" /S /I /Y /R
start "" /wait "%ProgramFiles(x86)%\InstallShield Installation @R_856_4045@ion\{2EA86967-B3D3-4B2E-9DE9-28A595AF2E2E}\setup.exe" -runfromtemp -l0x0409 -removeonly /s /f1"%~dp0\uninstall.iss"
if not exist "C:\TempMPC" goto :eof
mkdir "C:\Test\Data">nul 2>&1
timeout /t 2 /nobreak > nul
robocopy "C:\TempMPC" "C:\Test\Data" /MIR
其中uninstall.iss
是响应文件,用于在卸载期间绕过用户输入,并且卸载成功。复制没有发生。但是,如果我删除下面的代码行,则可以正常工作。
start "" /wait "%ProgramFiles(x86)%\InstallShield Installation @R_856_4045@ion\{2EA86967-B3D3-4B2E-9DE9-28A595AF2E2E}\setup.exe" -runfromtemp -l0x0409 -removeonly /s /f1"%~dp0\uninstall.iss"
解决方法
未经测试,请尝试以下方法:
@echo off
if not exist exist "C:\Test\Data" goto :eof
mkdir "C:\TempMPC">nul 2>&1
robocopy "C:\Test\Data" "C:\TempMPC" /MIR
start "" /wait "%ProgramFiles(x86)%\InstallShield Installation Information\{2EA86967-B3D3-4B2E-9DE9-28A595AF2E2E}\setup.exe" -runfromtemp -l0x0409 -removeonly /s /f1
if not exist "C:\TempMPC" goto :eof
mkdir "C:\Test\Data">nul 2>&1
timeout /t 2 /nobreak > nul
robocopy "C:\TempMPC" "C:\Test\Data" /MIR