靜默安裝SqlServer2008指令碼

luckyfriends發表於2015-04-07
在命令列或者批處理檔案中執行“setup.exe /ConfigurationFile=ConfigurationFile.INI /Q”命令即可。“/ConfigurationFile”參數列示使用配置檔案,“/Q”參數列示靜默安裝無需使用者互動。
@echo off
setlocal EnableDelayedExpansion

set LOG_FILE=%cd%\setup.log
echo "--------------Begin to install SQL Server---------------" >%LOG_FILE%
"C:\Program Files (x86)\WinRAR\winrar.exe" x SQL2008.7z  >> %LOG_FILE%
set EXIT_CODE=%errorlevel%
if %EXIT_CODE% neq 0 (
echo "Extract 7z file failed." >> %LOG_FILE%
goto END
)

echo Y|cacls C:\SQL /T /P Administrators:F SYSTEM:F
set EXIT_CODE=%errorlevel%
if %EXIT_CODE% neq 0 (
echo "Cacls files failed." >> %LOG_FILE%
goto END
)

setup.exe /ConfigurationFile=SQL_install_ConfigurationFile.INI /Q
set EXIT_CODE=%errorlevel%
if %EXIT_CODE% neq 0 (
echo "Install SQL Server failed." >> %LOG_FILE%
goto END
)

echo "-----------Install SQL Server successfully-------------" >> %LOG_FILE%

:END
exit %EXIT_CODE%

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14710393/viewspace-1518365/,如需轉載,請註明出處,否則將追究法律責任。

相關文章