This is an old revision of the document!
Mit diesem Script werden so lange Updates intstalliert bis keine mehr vorliegen. Die Updates werden nur nach 19 Uhr und vor 7 Uhr installiert um den User nicht an der Anmeldung zu hindern. Aussnahme: Der Rechner wurde neu installiert, dann werden unabhängig von der Uhrzeit alle Updates installiert. Mit dem ONCE Script werden immer alle Updates installiert, unabhänig von der Tageszeit.
Voraussetzungen: Powershell Version >= 4
setup64.ins
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/en/credits/
; comment
[Actions]
requiredWinstVersion >= "4.11.4.7"
AutoActivityDisplay = true
StayOnTop = false
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $ExitCode$
DefStringList $Version_List$
DefVar $Version$
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts,
; no white space use '-' as a seperator
Set $ProductId$ = "install-windows-updates"
Set $MinimumSpace$ = "500 MB"
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
isFatalError
; Stop process and set installation status to failed
else
comment "Show product picture"
ShowBitmap "%ScriptPath%\windows_update_icon.png" "Windows Update"
Message "Prüfe, ob Powershell Version >= 4 ist..."
set $Version_List$ = getOutStreamFromSection ("DosInAnIcon_PSVersion_check")
set $Version$ = takeString(2, $Version_List$)
if ($Version$ < "4")
Message "Powershell Version veraltet. Produkt Powershell auf setup setzen..."
opsiServiceCall_Powershell_Setup
Message "Neustart..."
ExitWindows /ImmediateReboot
else
Message "Powershell Version ist >= 4..."
endif
Files_Install /Sysnative
Message "Installiere Windows Updates. Dies kann mehrere Stunden dauern."
DosInAnIcon_WindowsUpate
Sub_check_exitcode
endif
[DosInAnIcon_PSVersion_check]
powershell.exe $PSVersionTable.PSVersion.Major
[Files_Install]
CheckTargetPath = "%Systemdrive%\tmp"
copy -u "%ScriptPath%\install-updates.ps1" "%Systemdrive%\temp\"
[DosInAnIcon_WindowsUpate]
"%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy ByPass -command "& { "%Systemdrive%\temp\install-updates.ps1"; exit $lastexitcode }"
[opsiServiceCall_Powershell_Setup]
"method": "setProductActionRequestWithDependencies"
"params": [
"powershell",
"%HostID%",
"setup"
]
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
ExitWindows /ImmediateReboot
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
once64.ins
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/en/credits/
; comment
[Actions]
requiredWinstVersion >= "4.11.4.7"
AutoActivityDisplay = true
StayOnTop = false
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $ExitCode$
DefStringList $Version_List$
DefVar $Version$
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts,
; no white space use '-' as a seperator
Set $ProductId$ = "install-windows-updates"
Set $MinimumSpace$ = "500 MB"
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
isFatalError
; Stop process and set installation status to failed
else
comment "Show product picture"
ShowBitmap "%ScriptPath%\windows_update_icon.png" "Windows Update"
Message "Prüfe, ob Powershell Version >= 4 ist..."
set $Version_List$ = getOutStreamFromSection ("DosInAnIcon_PSVersion_check")
set $Version$ = takeString(2, $Version_List$)
if ($Version$ < "4")
Message "Powershell Version veraltet. Produkt Powershell auf setup setzen..."
opsiServiceCall_Powershell_Setup
Message "Neustart..."
ExitWindows /ImmediateReboot
else
Message "Powershell Version ist >= 4..."
endif
Files_Install /Sysnative
Message "Installiere Windows Updates. Dies kann mehrere Stunden dauern."
DosInAnIcon_WindowsUpate
Sub_check_exitcode
endif
[DosInAnIcon_PSVersion_check]
powershell.exe $PSVersionTable.PSVersion.Major
[Files_Install]
CheckTargetPath = "%Systemdrive%\tmp"
copy -u "%ScriptPath%\install-updates-once.ps1" "%Systemdrive%\temp\"
[DosInAnIcon_WindowsUpate]
"%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -command "& { "%Systemdrive%\temp\install-updates-once.ps1"; exit $lastexitcode }"
[opsiServiceCall_Powershell_Setup]
"method": "setProductActionRequestWithDependencies"
"params": [
"powershell",
"%HostID%",
"setup"
]
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
ExitWindows /ImmediateReboot
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
control
[Package] version: 19 depends: incremental: False [Product] type: localboot id: install-windows-updates name: Updates für Windows installieren description: advice: version: 4.0 priority: -80 licenseRequired: False productClasses: setupScript: setup64.ins uninstallScript: updateScript: alwaysScript: onceScript: once64.ins customScript: userLoginScript: [ProductDependency] action: setup requiredProduct: powershell requiredStatus: installed requirementType: before