Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for netfxver.bat

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

  1. @ECHO OFF
  2. :: Check Windows version and command line argument (none allowed)
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. IF NOT  "%~2"==""           GOTO Syntax
  5.  
  6. SETLOCAL ENABLEDELAYEDEXPANSION
  7.  
  8. :: Display head to Standard Error, so it may be separated from the actual results
  9. 1>&2 ECHO.
  10. 1>&2 ECHO .NET Framework versions installed on this computer:
  11. 1>&2 ECHO.
  12.  
  13. :: Use prefixes if both 32 and 64 bit versions exist
  14. IF EXIST %windir%\Microsoft.NET\Framework64 (
  15. 	SET b32=	[32bit]  
  16. 	SET b64=	[64bit]  
  17. ) ELSE (
  18. 	SET b32=
  19. 	SET b64=
  20. )
  21.  
  22. :: List all 32 bit versions
  23. FOR /D %%A IN (%windir%\Microsoft.NET\Framework\*) DO (
  24. 	SET NETFx=%%~nxA
  25. 	ECHO %b32%	!NETFx:v=!
  26. )
  27.  
  28. :: List all 64 bit versions if any exists
  29. IF EXIST %windir%\Microsoft.NET\Framework64 (
  30. 	ECHO.
  31. 	FOR /D %%A IN (%windir%\Microsoft.NET\Framework64\*) DO (
  32. 		SET NETFx=%%~nxA
  33. 		ECHO %b64%	!NETFx:v=!
  34. 	)
  35. )
  36.  
  37. :: Check if a specified version is installed
  38. IF NOT "%~1"=="" (
  39. 	SET OK=1
  40. 	IF EXIST %windir%\Microsoft.NET\Framework\v%1.* (
  41. 		SET OK=0
  42. 	)
  43. 	IF EXIST %windir%\Microsoft.NET\Framework64\v%1.* (
  44. 		SET OK=0
  45. 	)
  46. )
  47. ENDLOCAL & EXIT /B %OK%
  48.  
  49.  
  50. :Syntax
  51. ECHO NETFxVer.bat,  Version 3.00 for Windows 2000 or later
  52. ECHO List installed .NET Framework versions, or check if specified one is installed
  53. ECHO.
  54. ECHO Usage:    NETFXVER.BAT  [ n.n ]
  55. ECHO.
  56. ECHO Where:    n.n   is the version to be checked, e.g. 3.5
  57. ECHO.
  58. ECHO Returns:  A list of all installed versions is displayed on screen.
  59. ECHO           If a version to be checked was specified, the return code
  60. ECHO           (ERRORLEVEL) will be 0 if it is installed, or 1 if not.
  61. ECHO.
  62. ECHO Written by Rob van der Woude
  63. ECHO http://www.robvanderwoude.com
  64.  

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