Is there a command line command to check which version of .NET is installed

I have a set of scripts to execute scripts. You can use scripts on any server of 2008. However, I need to check if .NET 3.5 is installed (before running the scripts) using the dos batch file. Is it possible?

I know that I can check if a file exists in C:\WINDOWS\Microsoft.NET\Framework\v3.5 , but it would be nice to have something more reliable.

I would like to check if it is really installed, and not just if the dir / file exists.

thank

+55
windows cmd batch-file
Jan 29 '09 at 19:06
source share
9 answers

Unfortunately, the best way is to check this directory. I’m not sure what you mean, but it’s “actually installed”, since .NET 3.5 uses the same CLR environment as .NET 3.0 and .NET 2.0, so all new functions end in new assemblies that live in this directory . In principle, if the directory exists, then 3.5 is installed.

The only thing I would like to add is to find the directory for maximum flexibility:

 %windir%\Microsoft.NET\Framework\v3.5 
+12
Jan 29 '09 at 19:15
source share

Since you said that you want to know if it is really installed, I believe that the best way (not reaching the version of a certain code) is to check the obviously named Install registry key. 0x1 means yes:

 C:\>reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5"| findstr Install Install REG_DWORD 0x1 InstallPath REG_SZ c:\WINNT\Microsoft.NET\Framework\v3.5\ 

This is also an official official method.

Other than that, I think the only way to be 100% sure is to actually run a simple console application compiled for your version of the framework. Personally, I find this unnecessary and trust the registry method just fine.

Finally, you can set up a test intranet site accessible from your server and sniff the User Agent to determine .NET versions. But this, of course, is not a package solution. Also see.

+67
Jul 29 2018-11-11T00:
source share

You mean that a DOS command like the one below does the job of displaying the installed .NET platforms:

 wmic /namespace:\\root\cimv2 path win32_product where "name like '%%.NET%%'" get version 

Then the following may be displayed:

 Version 4.0.30319 

WMIC is very useful once you learn it, much easier than coding WMI in scripts depending on what you want to achieve.

+16
Mar 22 2018-11-11T00:
source share

You can write yourself a small console application and use System.Environment.Version to find out the version. Scott Hanselman reports on this blog .

Or look in the registry for installed versions. HKLM \ Software \ Microsoft \ NETFramework Setup \ NDP

+5
Jan 29 '09 at 19:26
source share

If you intend to run a small console application, you can also install clrver.exe from the .NET SDK. I don’t think you can become cleaner than that. This is not my answer (but I agree), I found it here .

+4
Apr 28 '10 at 0:20
source share

REM Search for a CONFIG file, if it does not exit, the user does not have .Net framework 2.0 `

 SET FileName=%windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG IF EXIST %FileName% GOTO INSTALL_DIALER ECHO.You currently do not have the Microsoft(c) .NET Framework 2.0 installed. 
0
Jan 26 '14 at 17:56
source share

This works for me:

 @echo off SETLOCAL ENABLEEXTENSIONS echo Verify .Net Framework Version for /f "delims=" %%I in ('dir /B /A:D %windir%\Microsoft.NET\Framework') do ( for /f "usebackq tokens=1,3 delims= " %%A in (`reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\%%I" 2^>nul ^| findstr Install`) do ( if %%A==Install ( if %%B==0x1 ( echo %%I ) ) ) ) echo Do you see version v4.5.2 or greater in the list? pause ENDLOCAL 

2^>nul redirects errors to par.

0
Sep 24 '15 at 18:01
source share

you can check the installed C # compilers and the print version of .net:

 @echo off for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do ( set "l=" for /f "skip=1 tokens=2 delims=k" %%$ in ('"%%# #"') do ( if not defined l ( echo Installed: %%$ set l=%%$ ) ) ) echo latest installed .NET %l% 

csc.exe does not have the -version switch, but it prints the .net version in its logo. You can also try with msbuild.exe, but .net framework 1. * does not have msbuild.

0
Jan 07 '17 at 12:28
source share
-2
Oct. 15 '15 at 18:19
source share



All Articles