Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for hotfixes.bat

(view source code of hotfixes.bat as plain text)

  1. @ECHO OFF
  2. ECHO.
  3.  
  4. :: Check command line parameter
  5. IF NOT "%1"=="" IF /I NOT "%1"=="/V" GOTO Syntax
  6.  
  7. :: Check for correct Windows version
  8. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  9.  
  10. :: Keep variables local
  11. SETLOCAL
  12.  
  13. :: /V parameter set verbose display
  14. IF /I "%1"=="/V" SET Verbose=1
  15.  
  16. :: Gather info from the registry
  17. REGEDIT /E "%Temp%.\Hotfixes.dat" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix"
  18.  
  19. :: Display header
  20. ECHO Hotfixes installed on this PC:
  21. ECHO.
  22.  
  23. :: Summarize all hotfixes gathered from registry
  24. FOR /F "tokens=7 delims=\" %%a IN ('TYPE "%Temp%.\Hotfixes.dat" ^| FIND "[HKEY_"') DO FOR /F "tokens=1 delims=]" %%A IN ('ECHO.%%a ^| FIND "]"') DO CALL :Summarize "%%A"
  25.  
  26. :: Remove temporary file
  27. IF EXIST "%Temp%.\Hotfixes.dat" DEL "%Temp%.\Hotfixes.dat"
  28.  
  29. :: Done
  30. ENDLOCAL
  31. GOTO:EOF
  32.  
  33. :Summarize
  34. SETLOCAL
  35. SET Hotfix=%~1
  36. :: No more details required
  37. IF NOT "%Verbose%"=="1" (
  38. 	ECHO.%Hotfix%
  39. 	GOTO:EOF
  40. )
  41. :: Gather more details from the registry
  42. REGEDIT /E "%Temp%.\Hotfixes.dat" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\%~1"
  43. :: Retrieve the hotfix description from the temporary file we just created
  44. FOR /F "tokens=1* delims==" %%a IN ('TYPE "%Temp%.\Hotfixes.dat" ^| FIND /I "Fix Description"') DO SET Description=%%~b
  45. :: Escape brackets in the description, otherwise the ECHO command will fail
  46. IF DEFINED Description SET Description=%Description:(=^^^(%
  47. IF DEFINED Description SET Description=%Description:)=^^^)%
  48. :: The whitespace in the following line is a tab
  49. ECHO.%Hotfix%	%Description%
  50. ENDLOCAL
  51. GOTO:EOF
  52.  
  53. :Syntax
  54. ECHO Hotfixes.bat,  Version 2.00 for Windows NT 4 / 2000
  55. ECHO Displays a list of hotfixes installed locally
  56. ECHO.
  57. ECHO Usage:  HOTFIXES  [ /V ]
  58. ECHO.
  59. ECHO         /V  list both hotfix numbers and descriptions
  60. ECHO.
  61. ECHO Written by Rob van der Woude
  62. ECHO http://www.robvanderwoude.com
  63. GOTO:EOF
  64.  

page last modified: 2024-04-16; loaded in 0.0116 seconds