Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for listsdks.bat

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

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. IF NOT "%~2"=="" GOTO Syntax
  4. ECHO "%~1" | FIND.EXE "?" >NUL && GOTO Syntax
  5. ECHO "%~1" | FIND.EXE "/" >NUL && GOTO Syntax
  6. (REG.EXE Query /? 2>NUL) | FIND.EXE /I "/v Value" >NUL || GOTO Syntax
  7.  
  8. SETLOCAL ENABLEDELAYEDEXPANSION
  9. SET ReqKeyword=%1
  10. IF "%ReqKeyword%"=="" (SET RC=0) ELSE (SET RC=1)
  11. FOR /F "tokens=6 delims=\" %%A IN ('REG.EXE Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs') DO (
  12. 	SET SDK.KeyWord=
  13. 	SET SDK.Title=
  14. 	SET SDK.Version=
  15. 	FOR /F "tokens=3"  %%B IN ('REG.EXE Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\%%A /V KeyWord 2^>NUL ^| FIND.EXE "REG_SZ"') DO SET SDK.KeyWord=%%B
  16. 	IF /I "%ReqKeyword%"=="" (
  17. 		FOR /F "tokens=2*" %%B IN ('REG.EXE Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\%%A /V Title   2^>NUL ^| FIND.EXE "REG_SZ"') DO SET SDK.Title=%%C
  18. 		FOR /F "tokens=3"  %%B IN ('REG.EXE Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\%%A /V Version 2^>NUL ^| FIND.EXE "REG_SZ"') DO SET SDK.Version=%%B
  19. 		IF NOT "!SDK.Version!"=="" ECHO !SDK.KeyWord!	!SDK.Version!	!SDK.Title!
  20. 	) ELSE (
  21. 		IF /I "%ReqKeyword%"=="!SDK.KeyWord!" (
  22. 			FOR /F "tokens=2*" %%B IN ('REG.EXE Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\%%A /V Title   2^>NUL ^| FIND.EXE "REG_SZ"') DO SET SDK.Title=%%C
  23. 			FOR /F "tokens=3"  %%B IN ('REG.EXE Query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\%%A /V Version 2^>NUL ^| FIND.EXE "REG_SZ"') DO SET SDK.Version=%%B
  24. 			IF NOT "!SDK.Version!"=="" ECHO !SDK.Version!
  25. 			EXIT /B 0
  26. 		)
  27. 	)
  28. )
  29. ENDLOCAL & EXIT /B %RC%
  30.  
  31.  
  32.  
  33. :Syntax
  34. ECHO.
  35. ECHO ListSDKs.bat,  Version 1.00 for Windows XP and later
  36. ECHO List all Microsoft SDKs with their version number,
  37. ECHO or display the version number for a specified SDK.
  38. ECHO.
  39. ECHO Usage:  LISTSDKS  [ sdkname ]
  40. ECHO.
  41. ECHO Where:  sdkname   is the short name or keyword for an SDK
  42. ECHO.
  43. ECHO Notes:  Run LISTSDKS without command line arguments to find the keywords
  44. ECHO         for all SDKs. These keywords are found as registry values in the
  45. ECHO         subkeys of HKLM\Software\Microsoft\MicrosoftSDK\InstalledSDKs.
  46. ECHO         If sdkname was specified but not found, the batch file will exit
  47. ECHO         with return code ("errorlevel") 1. If this help screen is
  48. ECHO         displayed, the return code will be 2 (in NT4 and later).
  49. ECHO         This batch file uses REG.EXE version 3.0. Modify the code if you
  50. ECHO         want to use it with older REG versions.
  51. ECHO.
  52. ECHO Written by Rob van der Woude
  53. ECHO http://www.robvanderwoude.com
  54. IF "%OS%"=="Windows_NT" EXIT /B 2
  55.  

page last uploaded: 2017-04-06, 13:33