Click here to Skip to main content
15,883,809 members
Articles / Web Development / ASP.NET
Tip/Trick

Check which .NET Framework version is installed from command line

Rate me:
Please Sign up or sign in to vote.
4.88/5 (12 votes)
1 Nov 2012CPOL 84K   12   7
Check which .NET Framework version is installed from command line

Introduction 

This article will help you to know which .NET Framework version is installed from command line.

Check which .NET Framework version is installed from command line

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
IT Analyst/ Senior Software Engineer with 4+ years of experience in MS.NET Technologies

Comments and Discussions

 
SuggestionHere are latest versions Pin
Duzher13-Jun-18 4:51
Duzher13-Jun-18 4:51 
Questionnice Pin
Ankita M7-Mar-14 1:43
Ankita M7-Mar-14 1:43 
GeneralCongratulations Pin
pacogarciafer10-Dec-13 21:05
pacogarciafer10-Dec-13 21:05 
GeneralMy vote of 5 Pin
hims0562-Nov-12 0:47
hims0562-Nov-12 0:47 
Questionhow about 4.5? Pin
Member 40506751-Nov-12 22:47
Member 40506751-Nov-12 22:47 
AnswerRe: how about 4.5? Pin
Member 16781-Nov-12 23:44
Member 16781-Nov-12 23:44 
Here is class that I found on the web that I run from a console app. I don't remember exactly where I found it or I would give credit to the original author. The results are shown below after the class.


class CDotNetVersion
{
    public List<string> versionList { get; set; }
    public CDotNetVersion()
    {
        versionList = new List<string>();
    }
    public void GetVersion()
    {
        versionList = new List<string>();
        using (var ndpKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP"))
        {
            Action<RegistryKey, Action<RegistryKey, string>> processKids = (node, action) =>
            {
                foreach (var childname in node.GetSubKeyNames())
                    using (var child = node.OpenSubKey(childname))
                        action(child, childname);
            };
            Action<RegistryKey, Func<RegistryKey, bool>> visitDescendants = null;
            visitDescendants = (regkey, isDone) =>
            {
                if (!isDone(regkey))
                    processKids(regkey, (subkey, subkeyname) => visitDescendants(subkey, isDone));
            };
            processKids(ndpKey, (versionKey, versionKeyName) =>
            {
                if (Regex.IsMatch(versionKeyName, @"^v\d"))
                {
                    visitDescendants(versionKey, key =>
                    {
                        bool isInstallationNode = Equals(key.GetValue("Install"), 1) && key.GetValue("Version") != null;
                        if (isInstallationNode)
                            versionList.Add(
                                key.Name.Substring(ndpKey.Name.Length + 1)
                                + (key.GetValue("SP") != null ? ", service pack " + key.GetValue("SP") : "")
                                + " (" + key.GetValue("Version") + ") "
                            );
                        return isInstallationNode;
                    });
                }
            });
        }
    }
}

The results...
.Net Framework Version: v2.0.50727, service pack 2 (2.0.50727.5420) 
.Net Framework Version: v3.0, service pack 2 (3.0.30729.5420) 
.Net Framework Version: v3.5, service pack 1 (3.5.30729.5420) 
.Net Framework Version: v4\Client (4.5.50709) 
.Net Framework Version: v4\Full (4.5.50709) 
.Net Framework Version: v4.0\Client (4.0.0.0) 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.