; W2KHotFixes.kix, Version 1.00 for Windows 2000 ; Check if the specified hotfixes have been installed. ; Define arrays Dim $Checked[ 0 ] Dim $Listed[ 0 ] Dim $Installed[ 0 ] ; Define registry key $FixRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000" ; Initialize variables $Missing = 0 $Index1 = 0 $Index2 = 0 $Index3 = 0 $Index4 = 0 ; Specify hotfix list file If $List = 0 $List = "@ScriptDir\W2KHotFixes.lst" EndIf ; Check if hotfix list file exists If Exist( $List ) = 0 GoTo Syntax EndIf ; Read installed hotfixes from registry and store the results in an array :Loop1 $KeyName1 = EnumKey( "$FixRoot\", $Index1 ) If @ERROR = 0 :Loop2 $KeyName2 = EnumKey( "$FixRoot\$KeyName1", $Index2 ) If @ERROR = 0 $Installed[ $Index3 ] = "$KeyName1\$KeyName2" If $Debug = 1 ? "$$Installed[$Index3] = $KeyName1\$KeyName2" EndIf $Index2 = $Index2 + 1 $Index3 = $Index3 + 1 ReDim PRESERVE $Installed[ $Index3 ] GoTo Loop2 EndIf $Index1 = $Index1 + 1 GoTo Loop1 EndIf ; Read hotfixes from hotfix list file and store the results in an array If Open( 3, $List ) = 0 $x = ReadLine( 3 ) While @ERROR = 0 $Listed[ $Index4 ] = $x If $Debug = 1 ? "$$Listed[$Index4] = $x" EndIf $Index4 = $Index4 + 1 $x = ReadLine( 3 ) ReDim PRESERVE $Listed[ $Index4 ] Loop $x = Close( 3 ) Else ? "Hotfix list file not opened, error code: [" + @ERROR + "]" Exit 255 EndIf ; Check if every line from the hotfix list file ; is found in the array of installed hotfixes For Each $Element1 In $Listed If Trim( $Element1 ) <> "" $Checked = 0 For Each $Element2 In $Installed If $Element1 = $Element2 $Checked = 1 EndIf Next If $Checked = 0 $Missing = $Missing + 1 If $Verbose = 1 ? $Element1 + " is NOT installed" EndIf Else If $Verbose = 1 ? $Element1 + " is installed" EndIf EndIf EndIf Next ; Append empty line ? ; Exit with return code equal to missing hotfixes Exit $Missing :Syntax ? "W2KHotFixes.kix, Version 1.00 for Windows 2000" ? "Check if the specified hotfixes have been installed." ? ? "Usage: KIX32 W2KHOTFIXES.KIX [ $$Verbose=1 ] [ $$List=list.txt ] [ $$Debug=1 ]" ? ? "Where: $$Verbose=1 will display the result for individual hotfixes" ? " (default: return code equals number of missing hotfixes)" ? " $$List specifies a different hotfix list" ? " (default: W2KHotFixes.lst)" ? " $$Debug=1 will display extra information, for debugging purposes" ? ? "An external file contains the list of hotfixes to be checked." ? "Use one line per hotfix; use hotfix names found in the registry under" ? "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000], as in:" ? "SP5\KB822831" ? "SP5\KB824146" ? "for [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB822831]" ? "and [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB824146]." ? ? "Written by Rob van der Woude" ? "http://www.robvanderwoude.com" ? Exit 255