29

To troubleshoot an installation, sometimes I just want a quick answer to what version of .NET is installed.

Is there a way to determine the .NET Framework version on a standard Windows system, other than looking at the directories?

NOTE: This is not for a development machine, just out-of-the-box windows

The following works, but I'm looking for a simpler way.

dir %WINDIR%\Microsoft.Net\Framework\v*

Directory of C:\Windows\Microsoft.Net\Framework

07/13/2009  07:20 PM    <DIR>          v1.0.3705
07/13/2009  07:20 PM    <DIR>          v1.1.4322
01/20/2010  01:16 PM    <DIR>          v2.0.50727
07/13/2009  09:37 PM    <DIR>          v3.0
01/20/2010  01:02 PM    <DIR>          v3.5
02/10/2010  03:20 AM    <DIR>          v4.0.21006

UPDATE: Not a solution, but another cool directory formatted listing

dir %WINDIR%\Microsoft.Net\Framework\v* /O:-N /B

v4.0.21006
v3.5
v3.0
v2.0.50727
v1.1.4322
v1.0.3705
abatishchev
  • 98,240
  • 88
  • 296
  • 433
Noah
  • 15,080
  • 13
  • 104
  • 148
  • 1
    How do you want to use the information? In a script? Otherwise I don't know what would be simpler than a `dir` – Dirk Vollmar Feb 10 '10 at 17:03
  • This is for support; I was trying to help out my elderly father; Just imaging getting an older non computer person to type "dir %WINDIR%\Microsoft.Net\Framework\v*" over the phone. That's what started me thinking there must be a better way – Noah Feb 10 '10 at 17:12
  • Time to install CrossLoop on your dad's computer! :) – Dave Feb 10 '10 at 17:15
  • You should probably note in the question itself that you're not interested in this information specifically for development machines. – Mike Burton Feb 10 '10 at 17:17
  • @Noah: "NOTE: This is not for a development machine, just out-of-the-box windows" -- do you mean "out-of-the-box" literally? If so, then you can tell your father the .NET version he's got just by knowing Windows version. E.g. Windows 7 has 3.5 installed, XP with no SP doesn't have .NET at all, etc. – Igor Korkhov Feb 10 '10 at 17:45
  • @Igor -- Not literally, but a real good point that the windows version could give a lot of useful information about the problem. – Noah Feb 11 '10 at 01:38

7 Answers7

22
reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP" /s /v version | findstr /i version | sort /+26 /r

The top entry is the latest version of the framework installed.

Note: This doesn't work with v1.x of the framework.

Update: I missed the comment that you are looking for something to tell your dad over the phone. If that's the case, the command above is probably not the best approach for you. You might be better off just telling your dad to open Windows Explorer and navigate him to the .NET Framework dir and telling you the numbers in there.

Franci Penov
  • 74,861
  • 18
  • 132
  • 169
  • can this be done against machines across a network? IMO this is the best answer as it gives "patch" versions like 4.5 and 4.5.1 – BlackICE Mar 14 '14 at 12:28
  • 1
    The network version is simple: reg query "\\\HKLM\Software\Microsoft\NET Framework Setup\NDP" /s /v version | findstr /i version | sort /+26 – BlackICE Mar 14 '14 at 12:33
10

Based on your update which indicates this is for walking a non-tech savvy end user through it, I suggest going to Scott Hanselman's site http://www.smallestdotnet.com (use Internet Explorer) which uses the user agent string to tell you which .NET Framework you've got and gives you recommendations for getting up to the latest version in the most efficient manner.

Old Answer
With PowerShell you could do this (although the presence of PowerShell already implies at least .NET 2.0)

Get-ChildItem "$($Env:WinDir)\Microsoft.Net\Framework" -i mscorlib.dll -r |
    ForEach-Object { $_.VersionInfo.ProductVersion }

I don't know if there's a comparable way to get the version information in plain old crusty cmd.exe.

Josh
  • 68,005
  • 14
  • 144
  • 156
9

just open the VS2008 command prompt and type clrver

Dave
  • 14,618
  • 13
  • 91
  • 145
  • And end-user machine is not going to have VS2008. – Joe Feb 10 '10 at 17:16
  • 4
    thanks for the negative vote after the post was updated with information I didn't have at the time I suggested the answer. – Dave Feb 10 '10 at 17:23
  • 3
    I really think downvotes should cost more rep (and become free after you've achieved a certain rep yourself) so that downvotes are reserved for answers which are just flat out wrong. This answer doesn't warrant a downvote. – Josh Feb 10 '10 at 17:34
0

EDIT: my answer is irrelevant for the OP question (which was edited after I originally answered).

According to MSDN you can use the registry as well to check for installed versions.

In addition this site claims that there is a command line application called csc you can use - haven't tried it though, I use the registry way during installations I run.

Dror
  • 7,255
  • 3
  • 38
  • 44
0

There is an article posted on CodeProject that can do just exactly that plus its command line based.

Hope this helps.

Alexander
  • 23,432
  • 11
  • 63
  • 73
t0mm13b
  • 34,087
  • 8
  • 78
  • 110
0

The following would detect if .net framework 3.5 is installed or not.. and if not installed will install it. Just run this on the command prompt.

if exist "%WINDIR%\Microsoft.Net\Framework\v3.5" goto end start /wait .\Framework\dotnetfx.exe /q /norestart" :end 

If you want to detect other versions just replace v3.5 with v2.0 or v1.0 as the case may be. Further if .net is not detected the installation of the .net framework would be done in silent mode i.e. no ui or user interaction.

HotTester
  • 5,620
  • 15
  • 63
  • 97
-2

The highest version number from that directory listing is the installed version.

As you can see, any version includes all previous versions, so check for support of a specific version = check for that specific directory.

Joshua
  • 40,822
  • 8
  • 72
  • 132
  • 1
    "any version includes all previous versions" - no, it doesn't. v2.0 does not include 1.0, for instance. – Igor Korkhov Feb 10 '10 at 17:38
  • @Igor huh what? If you have 2.0 don't all 1.0 apps run? – Joshua Feb 10 '10 at 20:47
  • the question was about *installed versions* of the .NET Framework, and I didn't say anything about running v1.0 app under framework v2.0 – Igor Korkhov Feb 10 '10 at 21:25
  • Normally when asking "Is .NET framework version x installed" the reason is to run an application compiled for version x. – Joshua Feb 10 '10 at 23:53