Jump to content
Gonzalez

[C#] Get OS version

Recommended Posts

// snippet by t0fx //
// give credits if u use it //
using System;

namespace GetOS
{
class Program
{
static void Main(string[] args)
{
OperatingSystem osInfo = Environment.OSVersion;
string os = osInfo.ToString();
try
{

if (os.StartsWith("Microsoft Windows NT 6.0.6000.0"))
{
Console.WriteLine(os.Replace("Microsoft Windows NT 6.0.6000.0",
"Vista Enterprise"));
}

if (os.StartsWith("Microsoft Windows NT 5.1.2600"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 5.1.2600", "Windows XP"));

}

if (os.StartsWith("Microsoft Windows 4.10.1998"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 5.1.2600", "Windows 98"));
}

if (os.StartsWith("Microsoft Windows 4.10.2222"))
{
Console.WriteLine(
os.Replace("Microsoft Windows 4.10.2222", "Windows 98 SE"));
}

if (os.StartsWith("Microsoft Windows NT 5.0.2195"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 5.0.2195", "Windows 2000"));
}

if (os.StartsWith("Microsoft Windows 4.90.3000"))
{
Console.WriteLine(
os.Replace("Microsoft Windows 4.90.3000", "Windows Me"));

}

if (os.StartsWith("Microsoft Windows NT 5.2.3790"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 5.2.3790",
"Windows XP 64-bit Edition 2003"));
}

if (os.StartsWith("Microsoft Windows NT 5.2.3790"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 5.2.3790", "Windows Server 2003"));
}

if (os.StartsWith("Microsoft Windows NT 5.2.3790"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 5.2.3790",
"Windows XP Professional x64 Edition"));
}

if (os.StartsWith("Microsoft Windows NT 6.0.6001"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 6.0.6001", "Windows Vista"));
}

if (os.StartsWith("Microsoft Windows NT 5.2.4500"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 5.2.4500", "Windows Home Server"));
}

if (os.StartsWith("Microsoft Windows NT 6.1.7100"))
{
Console.WriteLine(
os.Replace("Microsoft Windows NT 6.1.7100", "Windows Seven"));

}
}
catch (Exception k)
{
Console.WriteLine("Error : " k);

}
}
}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...