Click here to Skip to main content
Click here to Skip to main content

Check which .NET Framework version is installed from command line

By , 1 Nov 2012
Rate this:
Please Sign up or sign in to vote.

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)

About the Author

Fenil Desai
Software Developer (Senior)
India India
IT Analyst/ Senior Software Engineer with 4+ years of experience in MS.NET Technologies
Follow on   Twitter   Google+

Comments and Discussions

 
Questionnice PinmemberAnkita M7-Mar-14 1:43 
GeneralCongratulations Pinmemberpacogarciafer10-Dec-13 21:05 
QuestionMessage Automatically Removed PingroupWisen Technologies17-Aug-13 2:46 
GeneralMy vote of 5 Pinmemberhims0562-Nov-12 0:47 
Questionhow about 4.5? PinmemberMember 40506751-Nov-12 22:47 
AnswerRe: how about 4.5? PinmemberMember 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    Rant Rant    Admin Admin   

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 2 Nov 2012
Article Copyright 2012 by Fenil Desai
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid