What's the foolproof way to tell which version(s) of .NET are installed on a production Windows Server?

113,762

Solution 1

You should open up IE on the server for which you are looking for this info, and go to this site: http://www.hanselman.com/smallestdotnet/

That's all it takes.

The site has a script that looks your browser's "UserAgent" and figures out what version (if any) of the .NET Framework you have (or don't have) installed, and displays it automatically (then calculates the total size if you chose to download the .NET Framework).

Solution 2

You can programmatically check the registry and a few other things as per this blog entry.

The registry key to look at is

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\...]

Solution 3

Found answer from here:

Check which .NET Framework version is installed

Open Command Prompt and copy paste one of the below command lines

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

or

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

Solution 4

The Microsoft way is this:

MSDN: How to determine Which .NET Framework Versions Are Installed (which directs you to the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\...)

If you want foolproof that's another thing. I wouldn't worry about an xcopy of the framework folder. If someone did that I would consider the computer broken.

The most foolproof way would be to write a small program that uses each version of .NET and the libraries that you care about and run them.

For a no install method, PowerBasic is an excellent tool. It creates small no runtime required exe's. It could automate the checks described in the MS KB article above.

Solution 5

As per CodeTrawler's answer, the solution is to enter the following into an explorer window:

%systemroot%\Microsoft.NET\Framework

Then search for:

Mscorlib.dll

...and right-click / go to the version tab for each result.

Share:
113,762

Related videos on Youtube

Tom Kidd
Author by

Tom Kidd

iOS developer

Updated on June 28, 2020

Comments

  • Tom Kidd
    Tom Kidd almost 4 years

    This question is not so much programming related as it is deployment related.

    I find myself conversing a lot with the group in my company whose job it is to maintain our production Windows servers and deploy our code on them. For legal and compliance reasons, I do not have direct visibility or any control over the servers so the only way I can tell which version(s) of .NET are installed on any of them is through directions I give to that group.

    So far, all of the methods I can think of to tell which version(s) are installed (check for Administrative Tools matching 1.1 or 2.0, check for the entries in the "Add/Remove Programs" list, check for the existence of the directories under c:\Windows\Microsoft.NET) are flawed (I've seen at least one machine with 2.0 but no 2.0 entries under Administrative Tools - and that method tells you nothing about 3.0+, the "Add/Remove Programs" list can get out of sync with reality, and the existence of the directories doesn't necessarily mean anything).

    Given that I generally need to know these things are in place in advance (discovering that "oops, this one doesn't have all the versions and service packs you need" doesn't really work well with short maintenance windows) and I have to do the checking "by proxy" since I can't get on the servers directly, what's the foolproof way to tell which version(s) of .NET are installed on a production Windows Server? Preferably some intrinsic way to do so using what the framework installs since it will be quicker and not need some sort of utility to be loaded and also a method which will definitely fail if the frameworks are not properly installed but still have files in place (i.e., there's a directory and gacutil.exe is inded there but that version of the framework is not really "installed")

    EDIT: In the absence of a good foolproof intrinsic way to do this built into the Framework(s), does anyone know of a good, lightweight, no-install-required program that can find this out? I can imagine someone could easily write one but if one already exists, that would be even better.

  • Tom Kidd
    Tom Kidd over 15 years
    And that might be the right way but the "what if?" in my head says "what if the files are there but the Framework isn't really 'installed' and some clueless admin thought copying the files over was the way to do it?"
  • Franci Penov
    Franci Penov over 15 years
    - if it's a production server, he might not even have access to it - browsing random sites on prod server is a big no-no - that site gives only the highest .Net version; he wants all of them
  • Tom Kidd
    Tom Kidd over 15 years
    Problem, looks like, with that approach is that it only tells you what the latest version you have is. I deploy code in 2.0, 3.0, 3.5 and (sadly) even 1.1. Although the goal is to get everything upgraded eventually, the sad fact for now is that I need all the different parallel versions.
  • Tom Kidd
    Tom Kidd over 15 years
    I can't tell - does this also cover 1.1?
  • Admin
    Admin about 14 years
    Are there any (licensing) issues with deploying just that executable? It doesn't have any dependencies to speak of.
  • kmote
    kmote about 12 years
    Although I agree this solution may not be appropriate for production servers, I upvoted it because it is certainly the simplest and quickest method for development machines (on which I have used it often). The current version of the script successfully detected all the different versions of .NET that I had installed.
  • Mosc
    Mosc about 11 years
    User Agent string from the provided URL: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0). Bu-ga-ga, so, what .NET Framework versions are installed? To achieve expected result need to switch IE to compatible mode.
  • Niall Connaughton
    Niall Connaughton almost 11 years
    I can see 1.1 details under this registry key on my system, so I'd say it does cover 1.1
  • Igor Mironenko
    Igor Mironenko over 10 years
    Exactly what I needed
  • Ronnie Petty
    Ronnie Petty over 10 years
    By the way you might want to set Main to private like this: private static void Main(string[] args) { }
  • Ronnie Petty
    Ronnie Petty over 10 years
    This is pretty much how Microsoft has it laid out on MSDN. msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx
  • Nick Patsaris
    Nick Patsaris over 10 years
    4.5 and 4.5.1 are installed in the place of 4.0, so this solution can be misleading. msdn.microsoft.com/en-us/library/5a4x27ek%28v=vs.110%29.aspx
  • Robert Calhoun
    Robert Calhoun over 9 years
    Scott Hanselman has certainly established his bona fides so I wouldn't call it a "random site". (Plus he makes the source code available.) But this app does require an Internet connection, which locked-in-a-Faraday-cage hosts frequently lack.
  • Scott Solmer
    Scott Solmer over 9 years
    This method no longer works for versions 4.5.1 and up
  • Siken
    Siken almost 9 years
    This seems to be the easiest way to differentiate between version 4 / 4.5+, otherwise, for an overview of what is installed, @K.Dias answer worked for me: dir %windir%\microsoft.net \framework\v* /O:-N /B
  • Off The Gold
    Off The Gold over 8 years
    Yea, looking under ...\NDP\v4\Full\, then in the version I could see I had v 4.5.5... The TargetVersion is set at 4.0.0
  • Roman Starkov
    Roman Starkov over 8 years
    clrver is useless, because it lies. It says 4.0.* for 4.5/4.6
  • kmote
    kmote over 8 years
    @Okuma.Scott - I have updated the link to the official MSDN instructions.
  • Kiquenet
    Kiquenet about 5 years
    latest version 4.7.2 ?