Last active
May 10, 2018 08:53
-
-
Save heiswayi/d34a9d06c83264508a24 to your computer and use it in GitHub Desktop.
List all installed .NET Framework versions in a PC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Win32; | |
using System; | |
namespace List_NET_Version_Installed | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(".NET Framework Versions"); | |
Console.WriteLine("======================="); | |
var hkNDP = Registry.LocalMachine.OpenSubKey( | |
@"SOFTWARE\Microsoft\NET Framework Setup\NDP", false); | |
WriteKey(hkNDP, ""); | |
hkNDP.Close(); | |
Console.ReadLine(); | |
} | |
static void WriteKey(RegistryKey hk, string relPath) | |
{ | |
if (relPath != "") | |
relPath += "/"; | |
foreach (var keyname in hk.GetSubKeyNames()) | |
{ | |
var key = hk.OpenSubKey(keyname, false); | |
var keySP = key.GetValue("SP"); | |
var keyVersion = key.GetValue("Version"); | |
if (keyVersion != null) | |
Console.WriteLine(relPath + keyname + | |
": Version " + keyVersion.ToString() + | |
((keySP != null) ? " SP " + keySP.ToString() : "") + | |
(1.Equals(key.GetValue("Install")) ? " installed" : "")); | |
WriteKey(key, relPath + keyname); | |
key.Close(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment