IDEA: Automate updating after Service Pack installation

IDEA: Automate updating after Service Pack installation

Postby imrumpf » 07.05.2012, 19:21

It always made me sad how awesome WSUSO was, yet it was never able to automate the process 100% as you had to manually resume the rest of WSUSO after the service pack installation. I have an idea/suggestion which may allow us to achieve such automation.

The concept/thought process:
1. Parameters that are to be passed onto the DoUpdate.cmd are passed to a file created in the user's startup folder
3. Install service pack
4. reboot
5. startup script parses all drives for DoUpdate.cmd, starts script with parameters defined earlier
6. Profit!

Proof:
I do not know autoit (Tried to look over the script, but couldn't figure out how to create the code I wanted), but I know how to make it work in my mind, and think we can make this work. There are 2 variables that need to be parsed, then placed into a cmd or bat file which is located in 1 of the 2 locations:
- %ALLUSERSPROFILE%\Start Menu\Programs\Startup (XP)
- %ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup (Vista/7)

1. The first variable would be the path that updateinstaller.exe was run MINUS the drive letter (Example: apps\Updates\WSUSO, we'll call this one %WSUSO_APP_PATH%)
2. The second variable would be the parameters that were checked off (Example: /verify /updatercerts /updatecpp /updatedx /updatewmp /updatetsc /instdotnet35 /instdotnet4, we'll call this one %WSUSO_PARAMS%)

The 2 varables are then injected into a file created in the startup folder.

The startup script template would look as so, with %***% being the variables:
Code: Select all
@ECHO OFF
FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (IF EXIST %%i:\%WSUSO_APP_PATH%\cmd\DoUpdate.cmd SET CDROM=%%i:)
start "" /High /I "%CDROM%\%WSUSO_APP_PATH%\cmd\DoUpdate.cmd" %WSUSO_PARAMS%


This is an example of what the resulting code in the file would look like:
Code: Select all
@ECHO OFF
FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (IF EXIST %%i:\wsusou\client\cmd\DoUpdate.cmd SET CDROM=%%i:)
start "" /High /I "%CDROM%\wsusou\client\cmd\DoUpdate.cmd" /verify /updatercerts /updatecpp /updatedx /updatewmp /updatetsc /instdotnet35 /instdotnet4



Thoughts:
This is something I have personally implemented as a workaround : I created a custom Service Pack install script and compiled everything onto 1 DVD. I run the DVD, the service pack files are copied to the PC and the installation is started. During this time I remove the DVD and I insert my WSUSO medium. I have 3 copies on DVD and 2 dedicated WSUSO USB keys. When the service pack installation process is complete, I have the above command run, but I have pre-coded both variables. It searches, finds WSUSO, and begins the rest of the process. It works really well, and I would love to see such feature implemented into WSUSO. This seems really easy to do, I'm just not currently capable of figuring out how to implement it, and I am very excited to try and contribute to the community :-)
imrumpf
 

Re: IDEA: Automate updating after Service Pack installation

Postby imrumpf » 11.06.2012, 14:48

I am a little surprised by the lack of responses on this topic, I guess I expected it to pique the communities interest. Perhaps my wording offended some? If that is the case, I do sincerely apologize, and I hope my contribution here will help as repayment ;-)

Moving forward, I have made progress on the concept, and have successfully merged it with WSUSO (without changing any of the core coding, to make it easy to integrate). I have a few more tweaks to make before i consider the script perfect for use, as you will see below.

Notes:
- Works with Windows XP (32), Windows Vista (32/64), and Windows 7 (32/64)
- Applies the HP/AMD BSOD patch on XP before SP3 install.
- Runs the 'Service Pack Cleanup Utility' (Vista/7)
- Installs Vista Platform Update after Service Pack installation
- Installs USB hotfix for windows 7 after service pack installation
- Is able to pass on the initial parameters set by UpdateInstaller.exe
- Copies service pack file to PC, WSUSO media can then be inserted into the PC as service pack installation is in progress
- As a result, a dedicated 'Service Pack Installation Disc' can be created which can contain all of the service packs on one DVD-5 (Using the 5-Language Service Packs, but the script will also support the All-Language packs)
- BUG: Requires WSUSO files to be in root directory of media after service pack installation is complete (F:\UpdateInstaller.exe)
- BUG: If initiated from Update.cmd, manually sets parameters (I was thinking of maybe having it parse the UpdateInstaller.ini in the future)
- BUG: Integration into WSUSO is poor, so it does not share variables, paths, logging, etc. This is a proof of concept currently.

You can initiate the update process one of 2 ways:
- Run UpdateInstaller.exe, after pressing start the script will run before the main WSUSO update
- run update.cmd (As Admin on UAC-based systems)

Files:

The only WSUSO-related file that needs to be edited is the update.cmd file in the root directory:
Code: Select all
@echo off
cd /D "%~dp0cmd\custom"
start spcopier.bat %*


The next 3 files are contained within 'cmd\custom'
spcopier.bat
Code: Select all
@ECHO OFF
CLS
CD /D "%~DP0"
MODE CON:COLS=51 LINES=8

SET SCAN4SP=N
SET SP_VER=RTM
FOR /F "TOKENS=2* DELIMS=    " %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CSDVersion"2^>NUL^') DO (SET SP_VER=%%B)
FOR /F "TOKENS=2* DELIMS=    " %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CurrentBuildNumber"2^>NUL^') DO (SET BUILDID=%%B)
IF EXIST "%PROGRAMFILES(x86)%" (SET BIT=x64) ELSE (SET BIT=x32)

IF %BUILDID% EQU 2600 GOTO SKIPUACCHECK
IF %BUILDID% GEQ 6000 (
   IF %BUILDID% LSS 7609 (
         BCDEDIT >NUL
         IF ERRORLEVEL 1 goto FAIL
      ) ELSE (
         GOTO END
   )
)
:SKIPUACCHECK

:SetParams
set BACKUP_MODE=/nobackup
set VERIFY_MODE=
IF %BUILDID% EQU 2600 (
      set INSTALL_IE=/instie8
   ) else (
      set INSTALL_IE=/instie9
)
set UPDATE_RCERTS=/updatercerts
set UPDATE_CPP=/updatecpp
set UPDATE_DX=/updatedx
set UPDATE_WMP=/updatewmp
set UPDATE_TSC=/updatetsc
set INSTALL_DOTNET35=/instdotnet35
set INSTALL_DOTNET4=/instdotnet4
set INSTALL_PSH=/instpsh
set INSTALL_MSSE=
set INSTALL_WD=/instwd
set INSTALL_OFC=/instofc
set INSTALL_OFV=/instofv
set BOOT_MODE=/autoreboot
set FINISH_MODE=
set SHOW_LOG=
set LIST_MODE_IDS=
set LIST_MODE_UPDATES=
set SKIP_DYNAMIC=

:EvalParams
if "%1"=="" goto NoMoreParams
if /i "%1"=="/nobackup" set BACKUP_MODE=/nobackup
if /i "%1"=="/verify" set VERIFY_MODE=/verify
if /i "%1"=="/instie7" set INSTALL_IE=/instie7
if /i "%1"=="/instie8" set INSTALL_IE=/instie8
if /i "%1"=="/instie9" set INSTALL_IE=/instie9
if /i "%1"=="/updatercerts" set UPDATE_RCERTS=/updatercerts
if /i "%1"=="/updatecpp" set UPDATE_CPP=/updatecpp
if /i "%1"=="/updatedx" set UPDATE_DX=/updatedx
if /i "%1"=="/updatewmp" set UPDATE_WMP=/updatewmp
if /i "%1"=="/updatetsc" set UPDATE_TSC=/updatetsc
if /i "%1"=="/instdotnet35" set INSTALL_DOTNET35=/instdotnet35
if /i "%1"=="/instdotnet4" set INSTALL_DOTNET4=/instdotnet4
if /i "%1"=="/instpsh" set INSTALL_PSH=/instpsh
if /i "%1"=="/instmsse" set INSTALL_MSSE=/instmsse
if /i "%1"=="/instwd" set INSTALL_WD=/instwd
if /i "%1"=="/instofc" set INSTALL_OFC=/instofc
if /i "%1"=="/instofv" set INSTALL_OFV=/instofv
if /i "%1"=="/autoreboot" set BOOT_MODE=/autoreboot
if /i "%1"=="/shutdown" set FINISH_MODE=/shutdown
if /i "%1"=="/showlog" set SHOW_LOG=/showlog
if /i "%1"=="/all" set LIST_MODE_IDS=/all
if /i "%1"=="/excludestatics" set LIST_MODE_UPDATES=/excludestatics
if /i "%1"=="/skipdynamic" set SKIP_DYNAMIC=/skipdynamic
shift /1
goto EvalParams
:NoMoreParams

IF %BUILDID% EQU 2600 (SET WSUS_OS=wxp\enu)
IF %BUILDID% EQU 6000 (IF /I "%BIT%" == "x64" (SET WSUS_OS=w60-x64\glb) ELSE (SET WSUS_OS=w60\glb))
IF %BUILDID% EQU 6001 (IF /I "%BIT%" == "x64" (SET WSUS_OS=w60-x64\glb) ELSE (SET WSUS_OS=w60\glb))
IF %BUILDID% EQU 7600 (IF /I "%BIT%" == "x64" (SET WSUS_OS=w61-x64\glb) ELSE (SET WSUS_OS=w61\glb))

:CHECK_FILES
SET SP_SOURCE="%~DP0..\..
SET SP_DEST="%WINDIR%\Temp\Service Pack Installation Files

IF %BUILDID% EQU 2600 (
   IF /I "%SP_VER%" == "Service Pack 3" (GOTO END)
   IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\WindowsXP-KB936929-SP3-x86-ENU.exe" (GOTO NOFILE)
   GOTO INSTALLQ
)

:Check for ALG or 5LG SP File
IF %BUILDID% EQU 6000 (
   IF /I "%BIT%" == "x64" (
         IF EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB936330-X64-wave0.exe" (
               SET W60X64SP1=Windows6.0-KB936330-X64-wave0.exe
            ) ELSE (
               IF EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB936330-X64-wave1.exe" (
                     SET W60X64SP1=Windows6.0-KB936330-X64-wave1.exe
                  ) ELSE (
                     GOTO NOFILE
               )
         )
      ) ELSE (
         IF EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB936330-X86-wave0.exe" (
               SET W60X86SP1=Windows6.0-KB936330-X86-wave0.exe
            ) ELSE (
               IF EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB936330-X86-wave1.exe" (
                     SET W60X86SP1=Windows6.0-KB936330-X86-wave1.exe
                  ) ELSE (
                     GOTO NOFILE
               )
         )
   )
   SET CHECKVSP2=Y
)

IF %BUILDID% EQU 6001 SET CHECKVSP2=Y
IF /I "%CHECKVSP2%" == "Y" (
   IF /I "%BIT%" == "x64" (
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB948465-X64.exe" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB960362-x64.msu" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971512-x64.msu" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971513-x64.msu" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971514-x64.msu" (GOTO NOFILE)
      ) ELSE (
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB948465-X86.exe" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB960362-x86.msu" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971512-x86.msu" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971513-x86.msu" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971514-x86.msu" (GOTO NOFILE)

   )
   GOTO INSTALLQ
)

IF %BUILDID% EQU 7600 (
   IF /I "%BIT%" == "x64" (
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\windows6.1-KB976932-X64.exe" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.1-KB2529073-x64.msu" (GOTO NOFILE)
      ) ELSE (
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\windows6.1-KB976932-X86.exe" (GOTO NOFILE)
         IF NOT EXIST %SP_SOURCE%\%WSUS_OS%\Windows6.1-KB2529073-x86.msu" (GOTO NOFILE)
   )
   GOTO INSTALLQ
)

GOTO END

:FAIL
CLS
MODE CON:COLS=51 LINES=12
ECHO  
ECHO              !!!!!! ERROR !!!!!!
ECHO.
ECHO     Not Admin, please run as Administrator!
PAUSE >NUL
PAUSE >NUL
EXIT

:NOFILE
CLS
MODE CON:COLS=51 LINES=12
ECHO  
ECHO              !!!!!! ERROR !!!!!!
ECHO.
ECHO  This PC requires Service Packs but some files are
ECHO   missing from media.
ECHO.
ECHO  - I have files on another media [D]
ECHO  - Do not install [N]
echo.
SET C=Q
SET /P C= What would you like to do? [d/n]
IF /I "%C%" == "D" (SET SCAN4SP=Y) && (GOTO HPXPAMDSP3Q)
IF /I "%C%" == "N" (GOTO END)
GOTO NOFILE

:INSTALLQ
cls
ECHO 
ECHO                ====== INFO ======
ECHO.
ECHO      There are Service Packs available to be
ECHO           installed on this computer!
ECHO.
SET C=Q
SET /P C= Would you like to install? [y/n]
IF /I "%C%" == "N" GOTO END
IF /I "%C%" == "Y" GOTO HPXPAMDSP3Q
goto INSTALLQ

:HPXPAMDSP3Q
IF %BUILDID% NEQ 2600 (GOTO SETOFFLINE)
CLS
ECHO.
ECHO                !!!!!! WARNING !!!!!!
ECHO.
ECHO  Installing SP3 on an HP OEM PC with an AMD
ECHO  Processor will cause XP to BSOD. Patch available.
ECHO.
SET C=Q
SET /P C= Apply the BSOD patch? [y/n]
IF /I "%C%"=="N" (SET HPXPAMDSP3=N) && (GOTO SETOFFLINE)
IF /I "%C%"=="Y" (SET HPXPAMDSP3=Y) && (GOTO SETOFFLINE)
goto HPXPAMDSP3Q

:SETOFFLINE
CLS
SET C=Q
ECHO.
ECHO                ?????? QUESTION ??????
ECHO.
ECHO   After Service Pack installation is complete, you
ECHO    can also automatically install offline updates.
ECHO.
SET /P C= Update after Service Pack installation? [y/n]
IF /I "%C%" == "N" (SET OFFLINE=N) && (GOTO INSTRUCTIONS)
IF /I "%C%" == "Y" (SET OFFLINE=Y) && (GOTO INSTRUCTIONS)
GOTO SETOFFLINE

:INSTRUCTIONS
MODE CON:COLS=51 LINES=16
CLS
ECHO.
ECHO              ===== INSTRUCTIONS =====
ECHO.
ECHO  After process begins, Service Pack files will
ECHO  be copied to the PC and the machine then will be
ECHO  rebooted to begin. Make sure work is saved!
ECHO.
ECHO  During this time you may remove the Service Pack
ECHO  installation media. If you opted to install the
ECHO  offline updates, please make sure the media is
ECHO  inserted into the PC BEFORE the Service Pack
ECHO  installation is complete to avoid any errors.
ECHO.
ECHO.
SET C=Q
SET /P C= Are you ready to begin? [y/n]
IF /I "%C%" == "N" GOTO END
IF /I "%C%" == "Y" GOTO START
GOTO INSTRUCTIONS


:START
CLS
MODE CON:COLS=51 LINES=16
TITLE Service Pack Copier
IF NOT EXIST %SP_DEST% (MKDIR %SP_DEST%)

IF /I "%SCAN4SP%" == "N" (GOTO FINISH_SCAN4SP)
CLS
ECHO.
ECHO.
ECHO   - Scanning for files
FOR %%A IN (Z Y X W V U T S R Q P O N M L K J I H G F E D) DO (IF EXIST %%A:\cmd\custom\spcopier.bat (SET SP_SOURCE=%%A:)&&(GOTO FINISH_SCAN4SP))
GOTO START
:FINISH_SCAN4SP

ECHO.
IF %BUILDID% EQU 2600 (
   IF /I "%HPXPAMDSP3%" == "Y" (
      ECHO  - Applying HP XP AMD SP3 BSOD fix
      %WINDIR%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\intelppm /v Start /t REG_DWORD /d 4 /f >NUL
      %WINDIR%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\intelppm /v Start /t REG_DWORD /d 4 /f >NUL
      %WINDIR%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\intelppm /v Start /t REG_DWORD /d 4 /f >NUL
   )
)

IF %BUILDID% GEQ 6000 (
   IF %BUILDID% LEQ 7699 (
      ECHO  - Disabling UAC
      %WINDIR%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f >NUL
   )
)

:COPY
ECHO  - Copying installation files

IF %BUILDID% EQU 2600 (
   COPY /Y %SP_SOURCE%\%WSUS_OS%\WindowsXP-KB936929-SP3-x86-ENU.exe" %SP_DEST%" >NUL
)
IF %BUILDID% EQU 6000 (
   IF "%BIT%" == "x64" (
         COPY /Y %SP_SOURCE%\%WSUS_OS%\%W60X64SP1%" %SP_DEST%\Windows6.0-KB936330-X64.exe" >NUL
      ) ELSE (
         COPY /Y %SP_SOURCE%\%WSUS_OS%\%W60X86SP1%" %SP_DEST%\Windows6.0-KB936330-X86.exe" >NUL
   )
   SET COPYVSP2=Y
)
IF %BUILDID% EQU 6001 (SET COPYVSP2=Y)
IF /I "%COPYVSP2%" == "Y" (
   IF "%BIT%" == "x64" (
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB948465-X64.exe" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB960362-x64.msu" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971512-x64.msu" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971513-x64.msu" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971514-x64.msu" %SP_DEST%" >NUL
      ) ELSE (
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB948465-X86.exe" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB960362-x86.msu" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971512-x86.msu" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971513-x86.msu" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.0-KB971514-x86.msu" %SP_DEST%" >NUL
   )
)

IF %BUILDID% EQU 7600 (
   IF "%BIT%" == "x64" (
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.1-KB976932-x64.exe" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.1-KB2529073-x64.msu" %SP_DEST%" >NUL
      ) ELSE (
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.1-KB976932-x86.exe" %SP_DEST%" >NUL
         COPY /Y %SP_SOURCE%\%WSUS_OS%\Windows6.1-KB2529073-x86.msu" %SP_DEST%" >NUL
   )
)

::Copy startup script
IF %BUILDID% EQU 2600 (
      COPY /Y "%~DP0startsp.bat" "%ALLUSERSPROFILE%\Start Menu\Programs\Startup\Service Pack Installer.bat" >NUL
   ) ELSE (
      COPY /Y "%~DP0startsp.bat" "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup\Service Pack Installer.bat" >NUL
)

::Copy cleanup script
COPY /Y "%~DP0spcleanup.bat" "%WINDIR%\Temp" >NUL

::Create offline update file
IF /I "%OFFLINE%" == "N" (GOTO SKIPSETWSUSO)
   CD /D "%WINDIR%\Temp"
      echo @ECHO OFF >start_wsuso.bat
      echo CD /d "%%~DP0" >>start_wsuso.bat
      echo :SCAN4WSUSO >>start_wsuso.bat
      echo CLS >>start_wsuso.bat
      echo ECHO. >>start_wsuso.bat
      echo ECHO  - Scanning for offline updates >>start_wsuso.bat
      echo FOR %%%%A IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (IF EXIST %%%%A:\cmd\DoUpdate.cmd (SET WSUSODRIVE=%%%%A:)) >>start_wsuso.bat
      echo IF NOT "%%WSUSODRIVE%%" == "" GOTO STARTWSUSO >>start_wsuso.bat
      echo GOTO SCAN4WSUSO >>start_wsuso.bat
      echo :STARTWSUSO >>start_wsuso.bat
      echo CD /D "%%WSUSODRIVE%%\cmd" >>start_wsuso.bat
      echo start DoUpdate.cmd %BACKUP_MODE% %VERIFY_MODE% %INSTALL_IE% %UPDATE_RCERTS% %UPDATE_CPP% %UPDATE_DX% %UPDATE_WMP% %UPDATE_TSC% %INSTALL_DOTNET35% %INSTALL_DOTNET4% %INSTALL_PSH% %INSTALL_MSSE% %INSTALL_WD% %INSTALL_OFC% %INSTALL_OFV% %BOOT_MODE% %FINISH_MODE% %SHOW_LOG% %LIST_MODE_IDS% %LIST_MODE_UPDATES% %SKIP_DYNAMIC% >>start_wsuso.bat
      echo exit >>start_wsuso.bat
:SKIPSETWSUSO

::Reboot
shutdown /r /f /t 00
EXIT

:END
cd /D "%~dp0.."
IF EXIST "%~DP0..\DoUpdate.cmd" (
   start DoUpdate.cmd %BACKUP_MODE% %VERIFY_MODE% %INSTALL_IE% %INSTALL_IE% %INSTALL_IE% %UPDATE_RCERTS% %UPDATE_CPP% %UPDATE_DX% %UPDATE_WMP% %UPDATE_TSC% %INSTALL_DOTNET35% %INSTALL_DOTNET4% %INSTALL_PSH% %INSTALL_MSSE% %INSTALL_WD% %INSTALL_OFC% %INSTALL_OFV% %BOOT_MODE% %FINISH_MODE% %SHOW_LOG% %LIST_MODE_IDS% %LIST_MODE_UPDATES% %SKIP_DYNAMIC%
   exit
)
EXIT

startsp.bat
Code: Select all
@echo off
CD /d "%windir%\Temp\Service Pack Installation Files"
SET SERPAK=RTM
FOR /F "TOKENS=2* DELIMS=    " %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CSDVersion"2^>NUL^') DO (SET SERPAK=%%B)
FOR /F "TOKENS=2* DELIMS=    " %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CurrentBuildNumber"2^>NUL^') DO (SET BUILDID=%%B)
IF EXIST "%PROGRAMFILES(x86)%" (SET BIT=x64) ELSE (SET BIT=x32)

IF %buildid% EQU 2600 (
   IF /I "%serpak%" == "Service Pack 3" (
         GOTO NOSP
      ) ELSE (
         start "" /I /High WindowsXP-KB936929-SP3-x86-ENU.exe /passive /forcerestart /forceappsclose /log:%windir%\Temp\XP_SP3_Installation_Log.txt
   )
   GOTO:EOF
)

IF %buildid% EQU 6000 (
   IF /I "%BIT%" == "x64" (
         start "" /I /High Windows6.0-KB936330-X64.exe /unattend /nodialog /forcerestart
      ) ELSE (
         start "" /I /High Windows6.0-KB936330-X86.exe /unattend /nodialog /forcerestart
   )
   GOTO:EOF
)

IF %buildid% EQU 6001 (
   IF /I "%BIT%" == "x64" (
         start "" /I /High Windows6.0-KB948465-X64.exe /unattend /nodialog /forcerestart
      ) ELSE (
         start "" /I /High Windows6.0-KB948465-X86.exe /unattend /nodialog /forcerestart
   )
   GOTO:EOF
)

IF %buildid% EQU 7600 (
   IF /I "%BIT%" == "x64" (
         start "" /I /High Windows6.1-KB976932-x64.exe /unattend /nodialog /forcerestart
      ) ELSE (
         start "" /I /High Windows6.1-KB976932-x86.exe /unattend /nodialog /forcerestart
   )
   GOTO:EOF
)

:NOSP
CD /D "%windir%\Temp"
START spcleanup.bat
EXIT

spcleanup.bat
Code: Select all
@ECHO OFF
CD /d %~DP0
TITLE Service Pack Cleanup

ECHO.
ECHO.
ECHO    ============================================
ECHO       Service Pack Post-Installation Cleanup
ECHO    ============================================
ECHO.

SET SERPAK=RTM
FOR /F "TOKENS=2* DELIMS=    " %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CSDVersion"2^>NUL^') DO (SET SERPAK=%%B)
FOR /F "TOKENS=2* DELIMS=    " %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "CurrentBuildNumber"2^>NUL^') DO (SET BUILDID=%%B)
IF EXIST "%PROGRAMFILES(x86)%" (SET BIT=x64) ELSE (SET BIT=x32)

IF %BUILDID% EQU 6000 GOTO ERROR
IF %BUILDID% EQU 6001 GOTO ERROR
IF %BUILDID% EQU 7600 GOTO ERROR
IF %BUILDID% EQU 2600 (IF /I "%serpak%"=="Service Pack 3" (GOTO XPCOMPLETE) ELSE (GOTO ERROR))
IF EXIST "%WINDIR%\Temp\skipspcu.ini" (goto uaccomplete)
ECHO  - Running Service Pack Cleanup Utility
ECHO.
IF %BUILDID% EQU 6002 GOTO VISTACLEANUP
IF %BUILDID% EQU 7601 GOTO SEVENCLEANUP

:VISTACLEANUP
CD /D "%WINDIR%\System32"
start "" /Wait /I /High COMPCLN.exe /quiet
ECHO  - Installing Windows Vista Platform Update
CD /D "%WINDIR%\Temp\Service Pack Installation Files"
IF "%BIT%" == "x64" (
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB971513-x64.msu /quiet /norestart
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB971512-x64.msu /quiet /norestart
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB971514-x64.msu /quiet /norestart
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB960362-x64.msu /quiet /norestart
   ) ELSE (
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB971513-x86.msu /quiet /norestart
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB971512-x86.msu /quiet /norestart
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB971514-x86.msu /quiet /norestart
      START "" /Wait /I /High wusa.exe .\Windows6.0-KB960362-x86.msu /quiet /norestart      
)
CD /D "%WINDIR%\Temp"
echo. >> skipspcu.ini
shutdown /r /f /t 00
EXIT

:SEVENCLEANUP
CD /D "%WINDIR%\System32"
START "" /Wait /I /High DISM /online /cleanup-image /spsuperseded
ECHO  - Installing Windows 7 Post-SP1 USB hotfix - KB2529073
CD /D "%WINDIR%\Temp\Service Pack Installation Files"
IF "%BIT%" == "x64" (
      START "" /Wait /I /High wusa.exe .\Windows6.1-KB2529073-x64.msu /quiet /norestart
   ) else (
      START "" /Wait /I /High wusa.exe .\Windows6.1-KB2529073-x86.msu /quiet /norestart
)
CD /D "%WINDIR%\Temp"
echo. >> skipspcu.ini
shutdown /r /f /t 00
EXIT

:ERROR
ECHO  !!ERROR!! You only have %serpak%!
ECHO         (Hopefully not a bug in the script)
ECHO.
PAUSE
GOTO END

:UACCOMPLETE
ECHO  - Re-enabling UAC
%WINDIR%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f >nul

:XPCOMPLETE
ECHO  - Deleting Installation files
rd "%WINDIR%\Temp\Service Pack Installation Files" /S /Q 2>nul
ECHO  - Removing Startup script
IF %BUILDID% EQU 2600 (
      DEL "%ALLUSERSPROFILE%\Start Menu\Programs\Startup\Service Pack Installer.bat" /F /Q 2>nul
   ) ELSE (
      DEL "%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup\Service Pack Installer.bat" /F /Q
)

IF NOT EXIST "%WINDIR%\Temp\start_wsuso.bat" (GOTO END)
CD /D "%WINDIR%\Temp"
START start_wsuso.bat
:END
exit


So, have a gander at the code, feedback is appreciated, and maybe we can work together to help enable WSUSO to automate the Service Pack process :)
imrumpf
 

Re: IDEA: Automate updating after Service Pack installation

Postby WSUSUpdateAdmin » 12.06.2012, 16:05

Hi and welcome, imrumpf,

imrumpf wrote:I am a little surprised by the lack of responses on this topic,[...]

Yes, I'm sorry for delay :oops: and thank you for your idea and your effort! :)

I'll think about your concept
imrumpf wrote:The concept/thought process:
1. Parameters that are to be passed onto the DoUpdate.cmd are passed to a file created in the user's startup folder
3. Install service pack
4. reboot
5. startup script parses all drives for DoUpdate.cmd, starts script with parameters defined earlier
6. Profit!

, but right now the main problem I see is the missing AutoLogon between 4) and 5), which you don't handle, do you?

Anyway, I should work on it and I hope to manage this during the next weeks.

Thanks again & regards
Torsten Wittrock
WSUSUpdateAdmin
Administrator
 
Posts: 2245
Joined: 07.07.2009, 14:38

Re: IDEA: Automate updating after Service Pack installation

Postby imrumpf » 12.06.2012, 17:05

Never thought of the Autologon issue, I'll work on it tonight and provide an update.
imrumpf
 

Re: IDEA: Automate updating after Service Pack installation

Postby WSUSUpdateAdmin » 03.07.2012, 15:33

Hi!

I just found out that the solution is much simpler than I thought before.
Pls. see http://trac.wsusoffline.net/browser/trunk (r369) for details.

Thanks & regards
Torsten Wittrock
WSUSUpdateAdmin
Administrator
 
Posts: 2245
Joined: 07.07.2009, 14:38


Return to Anregungen / Suggestions

Who is online

Users browsing this forum: No registered users and 192 guests

cron