I’m not sure where I came across this but it works well for me. The solution is to query for the existence of the following registry key:
So in my batch file I can simply use
reg query to do the work:
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.5" 2>nul if errorlevel 1 ( echo .NET Framework 4.5 is NOT installed ) else ( echo .NET Framework 4.5 is installed )
Note that there’s a more complicated way documented on MSDN, but the above method is easy to use from a batch file and works well for my purposes.
Hope that helps!