Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for w2khotfixes.kix

(view source code of w2khotfixes.kix as plain text)

  1. ; W2KHotFixes.kix,  Version 1.00 for Windows 2000
  2. ; Check if the specified hotfixes have been installed.
  3.  
  4. ; Define arrays
  5. Dim $Checked[ 0 ]
  6. Dim $Listed[ 0 ]
  7. Dim $Installed[ 0 ]
  8.  
  9. ; Define registry key
  10. $FixRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000"
  11.  
  12. ; Initialize variables
  13. $Missing = 0
  14. $Index1 = 0
  15. $Index2 = 0
  16. $Index3 = 0
  17. $Index4 = 0
  18.  
  19. ; Specify hotfix list file
  20. If $List = 0
  21. 	$List = "@ScriptDir\W2KHotFixes.lst"
  22. EndIf
  23.  
  24. ; Check if hotfix list file exists
  25. If Exist( $List ) = 0
  26. 	GoTo Syntax
  27. EndIf
  28.  
  29. ; Read installed hotfixes from registry and store the results in an array
  30. :Loop1
  31. $KeyName1 = EnumKey( "$FixRoot\", $Index1 )
  32. If @ERROR = 0
  33. 	:Loop2
  34. 	$KeyName2 = EnumKey( "$FixRoot\$KeyName1", $Index2 )
  35. 	If @ERROR = 0
  36. 		$Installed[ $Index3 ] = "$KeyName1\$KeyName2"
  37. 		If $Debug = 1
  38. 			? "$$Installed[$Index3] = $KeyName1\$KeyName2"
  39. 		EndIf
  40. 		$Index2 = $Index2 + 1
  41. 		$Index3 = $Index3 + 1
  42. 		ReDim PRESERVE $Installed[ $Index3 ]
  43. 		GoTo Loop2
  44. 	EndIf
  45. 	$Index1 = $Index1 + 1
  46. 	GoTo Loop1
  47. EndIf
  48.  
  49. ; Read hotfixes from hotfix list file and store the results in an array
  50. If Open( 3, $List ) = 0
  51. 	$x = ReadLine( 3 )
  52. 	While @ERROR = 0
  53. 		$Listed[ $Index4 ] = $x
  54. 		If $Debug = 1
  55. 			? "$$Listed[$Index4] = $x"
  56. 		EndIf
  57. 		$Index4 = $Index4 + 1
  58. 		$x = ReadLine( 3 )
  59. 		ReDim PRESERVE $Listed[ $Index4 ]
  60. 	Loop
  61. 	$x = Close( 3 )
  62. Else
  63. 	? "Hotfix list file not opened, error code: [" + @ERROR + "]"
  64. 	Exit 255
  65. EndIf
  66.  
  67. ; Check if every line from the hotfix list file
  68. ; is found in the array of installed hotfixes
  69. For Each $Element1 In $Listed
  70. 	If Trim( $Element1 ) <> ""
  71. 		$Checked = 0
  72. 		For Each $Element2 In $Installed
  73. 			If $Element1 = $Element2
  74. 				$Checked = 1
  75. 			EndIf
  76. 		Next
  77. 		If $Checked = 0
  78. 			$Missing = $Missing + 1
  79. 			If $Verbose = 1
  80. 				? $Element1 + " is NOT installed"
  81. 			EndIf
  82. 		Else
  83. 			If $Verbose = 1
  84. 				? $Element1 + " is installed"
  85. 			EndIf
  86. 		EndIf
  87. 	EndIf
  88. Next
  89.  
  90. ; Append empty line
  91. ?
  92.  
  93. ; Exit with return code equal to missing hotfixes
  94. Exit $Missing
  95.  
  96.  
  97. :Syntax
  98. ? "W2KHotFixes.kix,  Version 1.00 for Windows 2000"
  99. ? "Check if the specified hotfixes have been installed."
  100. ?
  101. ? "Usage:  KIX32 W2KHOTFIXES.KIX [ $$Verbose=1 ] [ $$List=list.txt ] [ $$Debug=1 ]"
  102. ?
  103. ? "Where:  $$Verbose=1  will display the result for individual hotfixes"
  104. ? "                    (default: return code equals number of missing hotfixes)"
  105. ? "        $$List       specifies a different hotfix list"
  106. ? "                    (default: W2KHotFixes.lst)"
  107. ? "        $$Debug=1    will display extra information, for debugging purposes"
  108. ?
  109. ? "An external file contains the list of hotfixes to be checked."
  110. ? "Use one line per hotfix; use hotfix names found in the registry under"
  111. ? "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000], as in:"
  112. ? "SP5\KB822831"
  113. ? "SP5\KB824146"
  114. ? "for [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB822831]"
  115. ? "and [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB824146]."
  116. ?
  117. ? "Written by Rob van der Woude"
  118. ? "http://www.robvanderwoude.com"
  119. ?
  120. Exit 255
  121.  

page last uploaded: 2017-08-21, 14:26