
答案1
常見的安裝程式確實有“靜默安裝”選項。例如,Innosetup 有用/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /DIR="C:\INSTALL\PATH"
於此目的的命令列選項,而 NSIS 安裝程式有/S /D=C:\Install Path\No Quotes Allowed Even If Space Present
.
看無人值守安裝了解更多。
當然,靜默安裝提供的選擇很少,例如您無法決定是安裝 32 位元還是 64 位元 R 軟體包,而是將兩者安裝。
作為範例,以下是我創建的批次文件,用於自動將 TeXmacs 和 maxima 安裝到教室的多媒體系統中。其中的兩個子程式可能有用。
setlocal
set "main_dir=%USERPROFILE%\DESKTOP"
set "TeXMacs_dir=%main_dir%\mathsofts\TeXMacs"
set "maxima_dir=%main_dir%\mathsofts\maxima"
call :silent_install_inno "%~dp0TeXmacs.exe" "%TeXMacs_dir%"
call :silent_install_nsis "%~dp0maxima.exe" "%maxima_dir%"
endlocal
exit /b
:silent_install_inno
:: parameters: %1--path to the installer executable
:: %2--installation path
start "" /wait %1 /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /DIR=%2
exit /b
:silent_install_nsis
:: parameters: %1--path to the installer executable
:: %2--installation path
:: note: NO QUOTES in %2 is allowed, so %~2 should be used to de-quote
start "" /wait %1 /S /D=%~2
exit /b