Friday, September 21, 2012

Quick and dirty SQL 2008 R2 SP2 Slipstreaming

So I've been working to automate SQL 2008 R2 installation.  When I realized I kept getting updates after the install, I decided to find a way to speed that up. 

I found a script to slipstream SP1 on Fran's blog here:

Quick way to create a SQL Server 2008 R2 installer with integrated SP1 (Slipstream)

But it was dealing with SP1.  So, a quick "replace" in Notepad++, and hey presto, it works for SP2 as well.  here's the batch file:

 @ECHO OFF
  
 ::File Verification
  
 IF NOT EXIST "C:\SQLServer2008R2_SP2\" GOTO ERROR
  
 IF NOT EXIST "C:\SQLServer2008R2SP2-KB2630458-x86-ENU.exe" GOTO ERROR
  
 IF NOT EXIST "C:\SQLServer2008R2SP2-KB2630458-x64-ENU.exe" GOTO ERROR
  
 IF NOT EXIST "C:\SQLServer2008R2SP2-KB2630458-IA64-ENU.exe" GOTO ERROR
  
 ::Extract each of the SQL Server 2008 R2 SP1 packages to C:\SQLServer2008R2_SP2\SP
  
 ECHO Extracting SP files to C:\SQLServer2008R2_SP2\SP...
  
 start /wait C:\SQLServer2008R2SP2-KB2630458-x86-ENU.exe /x:C:\SQLServer2008R2_SP2\SP
  
 ECHO Extract of SQLServer2008R2SP2-KB2630458-x86-ENU.exe Completed
  
 start /wait C:\SQLServer2008R2SP2-KB2630458-x64-ENU.exe /x:C:\SQLServer2008R2_SP2\SP
  
 ECHO Extract of SQLServer2008R2SP2-KB2630458-x64-ENU.exe Completed
  
 start /wait C:\SQLServer2008R2SP2-KB2630458-IA64-ENU.exe /x:C:\SQLServer2008R2_SP2\SP
  
 ECHO Extract of SQLServer2008R2SP2-KB2630458-IA64-ENU.exe Completed
  
 ECHO.
  
 ::Copy Setup.exe from the SP extracted location to the original source media location
  
 ECHO Copying Setup.exe to C:\SQLServer2008R2_SP2
  
 start /wait robocopy C:\SQLServer2008R2_SP2\SP C:\SQLServer2008R2_SP2 Setup.exe
  
 ECHO Setup.exe copied
  
 ECHO.
  
 ::Copy all files, not the folders, except the Microsoft.SQL.Chainer.PackageData.dll, in C:\SQLServer2008R2_SP2\SP\<architecture> to C:\SQLServer2008R2_SP2\<architecture> to update the original files
  
 ECHO Copying files to C:\SQLServer2008R2_SP2\
  
 start /wait robocopy C:\SQLServer2008R2_SP2\SP\x86 C:\SQLServer2008R2_SP2\x86 /XF Microsoft.SQL.Chainer.PackageData.dll
  
 ECHO Files from C:\SQLServer2008R2_SP2\SP\x86 copied
  
 start /wait robocopy C:\SQLServer2008R2_SP2\SP\x64 C:\SQLServer2008R2_SP2\x64 /XF Microsoft.SQL.Chainer.PackageData.dll
  
 ECHO Files from C:\SQLServer2008R2_SP2\SP\x64 copied
  
 start /wait robocopy C:\SQLServer2008R2_SP2\SP\ia64 C:\SQLServer2008R2_SP2\ia64 /XF Microsoft.SQL.Chainer.PackageData.dll
  
 ECHO Files from C:\SQLServer2008R2_SP2\SP\ia64 copied
  
 ECHO.
  
 ::Create or modify DefaultSetup.ini
  
 IF NOT EXIST "C:\SQLServer2008R2_SP2\x86\DefaultSetup.ini" GOTO CREATEINI
  
 ECHO Modifying DefaultSetup.ini
  
 TYPE C:\SQLServer2008R2_SP2\x86\DefaultSetup.ini > C:\SQLServer2008R2_SP2\x86\Temp_DefaultSetup.ini
  
 ECHO PCUSOURCE=".\SP" >> C:\SQLServer2008R2_SP2\x86\Temp_DefaultSetup.ini
  
 DEL C:\SQLServer2008R2_SP2\x86\DefaultSetup.ini
  
 REN C:\SQLServer2008R2_SP2\x86\Temp_DefaultSetup.ini DefaultSetup.ini
  
 ECHO.
  
 GOTO COPYINI
  
 :CREATEINI
  
 ECHO Creating or modifying DefaultSetup.ini
  
 ECHO ;SQLSERVER2008 R2 Configuration File > C:\SQLServer2008R2_SP2\x86\DefaultSetup.ini
  
 ECHO [SQLSERVER2008] >> C:\SQLServer2008R2_SP2\x86\DefaultSetup.ini
  
 ECHO PCUSOURCE=".\SP" >> C:\SQLServer2008R2_SP2\x86\DefaultSetup.ini
  
 ECHO.
  
 :COPYINI
  
 ::Copy DefaultSetup.ini from x86 to x64 and ia64 folders
  
 ECHO Copying DefaultSetup.ini from x86 to x64 and ia64 folders
  
 start /wait robocopy C:\SQLServer2008R2_SP2\x86 C:\SQLServer2008R2_SP2\x64 DefaultSetup.ini
  
 start /wait robocopy C:\SQLServer2008R2_SP2\x86 C:\SQLServer2008R2_SP2\ia64 DefaultSetup.ini
  
 ECHO.
  
 ECHO ==============================================================================
  
 ECHO OPERATION COMPLETED
  
 ECHO Use C:\SQLServer2008R2_SP2\Setup.exe to install SQL Server 2008 R2 + SP2
  
 ECHO ==============================================================================
  
 ECHO.
  
 GOTO FIN
  
 :ERROR
  
 ECHO ==============================================================================
  
 ECHO FILE VERIFICATION FAIL, PLEASE CHECK THE FOLLOWING:
  
 ECHO THE DIRECTORY C:\SQLServer2008R2_SP2\ EXISTS
  
 ECHO SQLServer2008R2SP2-KB2630458-x86-ENU.exe FILE IS LOCATED IN C:\
  
 ECHO SQLServer2008R2SP2-KB2630458-x64-ENU.exe FILE IS LOCATED IN C:\
  
 ECHO SQLServer2008R2SP2-KB2630458-IA64-ENU.exe FILE IS LOCATED IN C:\
  
 ECHO ==============================================================================
  
 ECHO.
  
 :FIN
  
 PAUSE
  

Thanks to Fran Lens for the heavy lifting. 

No comments:

Post a Comment