Skip to content

opsi.orgheader image

opsi.org
Views
WinstScripts >>

msservicepack

Document Actions
last edited 1 year ago by bwolf
Qualified for opsi 3.3
---------------------------------------------------------------------
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.

[Initial]
Message=Installiere Microsoft Windows Service Pack ...
LogLevel=2
ExitOnError=true
ScriptErrorMessages=on
TraceMode=off

[Aktionen]
DefVar $SollServicePackW2K$
DefVar $SollServicePackXP$
DefVar $SollServicePack$
DefVar $IstServicePack$
DefVar $MinimumSpaceXP$
;DefVar $ExitCode$

Set $SollServicePackW2K$ = "Service Pack 4"
Set $SollServicePackXP$  = "Service Pack 3"

;http://support.microsoft.com/?scid=kb%3Ben-us%3B947311&x=5&y=14
; 1100 MB peak usage during installation
;
Set $MinimumSpaceXP$ = "1100 MB"

; ExitCodes XP
; http://msdn.microsoft.com/en-us/library/aa368542(VS.85).aspx
;
; Error Codes
;
; These error codes are returned by the Windows Installer functions MsiExec.exe and InstMsi.exe. Note that any error in Winerror.h (such as ERROR_INVALID_DATA, included here) can be returned as well.
; 
; Note  The error codes ERROR_SUCCESS, ERROR_SUCCESS_REBOOT_INITIATED, and ERROR_SUCCESS_REBOOT_REQUIRED are indicative of success. If ERROR_SUCCESS_REBOOT_REQUIRED is returned, the installation completed successfully but a reboot is required to complete the installation operation.

; 
; Error code 	Value 	Description
; ERROR_SUCCESS 	0 	The action completed successfully.
; ERROR_SUCCESS_REBOOT_REQUIRED 	3010 	A restart is required to complete the install. This message is indicative of a success. This does not include installs where the ForceReboot action is run.

requiredWinstVersion >= "4.6"

DefVar $BootMode$
Set $BootMode$ = GetRegistryStringValue("[HKLM\SOFTWARE\opsi.org\general]bootmode")
if ($BootMode$ = "")
    Set $BootMode$ = EnvVar("BOOTMODE")
endif

; should the SP installed even if it is still on the system
; bootmode is not aviable under opsi....
DefVar $forceInstall$
Set $forceInstall$ = IniVar("force")

DefVar $RebootFlag$
DefVar $OS
Set $OS = EnvVar("OS")

DefVar $MinorOS$
    set $MinorOS$ = GetNTVersion
    Set $IstServicePack$ = GetRegistryStringValue("[HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion] CSDVersion")

    DefVar $WinstRegKey
    DefVar $RebootRegVar
    Set $WinstRegKey = "HKLM\SOFTWARE\opsi.org\winst"
    Set $RebootFlag$ = GetRegistryStringValue("["+$WinstRegKey+"] "+"RebootSpFlag")


    ; ###### W2K ########################

    if ($MinorOS$ = "Win2K")
        Set $SollServicePack$ = $SollServicePackW2K$        
        if not ($RebootFlag$ = "1")
            if ($SollServicePack$ = "Service Pack 4")
                if not ($forceInstall$ = "off" and $IstServicePack$ = $SollServicePack$)
                    stayontop=false
                    WinBatch_W2K_SrvPackSetup /waitonclose
                    ; pause "Ist das Service Pack fertig?"
                    stayontop=true
                    ; Reboot initialisieren ...
                    Set $RebootFlag$ = "1"
                    Registry_SaveRebootFlag
                    ExitWindows /ImmediateReboot
                endif
            endif
        else
            Set $RebootFlag$ = "0"
            Registry_SaveRebootFlag
        endif        
    endif ; W2K
    
    ; ###### XP  ########################
    
    if ($MinorOS$ = "WinXP")
        Set $SollServicePack$ = $SollServicePackXP$
        if not ($RebootFlag$ = "1")
            if ($SollServicePack$ = "Service Pack 3")
                if not ($forceInstall$ = "off" and $IstServicePack$ = $SollServicePack$)            
                  if not(HasMinimumSpace ("%SYSTEMDRIVE%", $MinimumSpaceXP$))
		    LogError "Not enough space on C: . "+$MinimumSpaceXP$+" auf C: fuer Servicepack 3 erforderlich."
		    isFatalError
		    ; Bearbeitung beenden und Produktschalter auf failed setzen
		  else
		    ExecWith_autoit "%SCRIPTPATH%\autoit3.exe" WINST /letThemGo /EscapeStrings 
                    stayontop=false
                    WinBatch_XP_SrvPackSetup  /waitonclose
                    ; pause "Ist das Service Pack fertig?"
                    stayontop=true    
		    killtask "autoit3.exe"                
                    ; Reboot initialisieren ...
                    Set $RebootFlag$ = "1"
                    Registry_SaveRebootFlag
                    ExitWindows /ImmediateReboot
                  endif
                endif
            endif
        else
            Set $RebootFlag$ = "0"
            Registry_SaveRebootFlag
        endif        
    endif ; XP
    
    ; ###################################





;#################### W2K ###################################

[WinBatch_W2K_SrvPackSetup]
%SCRIPTPATH%\w2k\w2ksp4_de.exe -u -z


;#################### XP  ###################################
[ExecWith_autoit]
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
WinWait("reg","")
Send("{ENTER}")
;WinWait("reg.exe","")
;Send("{ENTER}")
;WinWait("reg.exe","")
;Send("{ENTER}")
;exit

[WinBatch_XP_SrvPackSetup]
;%SCRIPTPATH%\xp\xpsp2.exe -u -z
%SCRIPTPATH%\xp\windowsxp-kb936929-sp3-x86-deu.exe -u -z /log:c:\tmp\winxpsrv3.log

;#################### Allgemein #############################

[Registry_SaveRebootFlag]
openKey [$WinstRegKey]
set "RebootSpFlag" = "$RebootFlag$"

;#################### END ###################################



file: http://www.opsi.org/opsi_wiki/Msservicepack/msservicepack.ins