0 Comments

There have been a number of posts on this already by Scott Hanselman and Rick Strahl, but I needed a simple way to detect if .NET 4.5 was installed from somewhere basic like a batch file.

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:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v4.0.30319\SKUs.NETFramework,Version=v4.5

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!