Code to check if XP Service Pack 3 Installed (And .net 3.5)

7.8k views Asked by At

I want to write a program (in vb.net) that checks a customers configuration to make sure that they're ...

  • Running XP service Pack 3
  • Running .Net 3.0 or above.
  • Give them a warning if they are not running .Net 3.5 or above.

or

  • Running Vista Service Pack 1.

How would I do this? There is a stackoverflow question asking how to tell which version of .NET is installed, but how do I test which O/S & O/S service pack is installed?

How to detect what .NET Framework versions and service packs are installed?

2

There are 2 answers

1
Alexander On BEST ANSWER

I do not exactly know the version number of Windows XP SP 3 (but should be easy to lookup for you), but here is how you can get version string.


Console.WriteLine(Environment.Version); // CLR version
Console.WriteLine(Environment.OSVersion.VersionString); // OS version string
Console.WriteLine(Environment.OSVersion.ServicePack); // OS SP string

Version requiredVersion = new Version(5, 1, 2600, 0); // Should be XP Prof. with Service Pack 2 (any revision) if (Environment.OSVersion.Version.Major >= requiredVersion.Major && Environment.OSVersion.Version.Minor >= requiredVersion.Minor && Environment.OSVersion.Version.Build >= requiredVersion.Build) { // You are running at least Windows XP Prof. with Service Pack 2 or above! }

Determin if .NET Framework 3.5 is installed won't be easy because the 3.5 version is only a addon based on 2.0. But you can check if the folder "C:\WINDOWS\Microsoft.NET\Framework\v3.5" does exist.

0
Christian Witts On