2

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?

Community
  • 1
  • 1
seanyboy
  • 5,623
  • 7
  • 43
  • 56

2 Answers2

3

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.

Alexander
  • 3,724
  • 8
  • 42
  • 50
  • Note that the code above requires a minor version >= 1. if the Windows version is more recent--say, 6.0 or some future 7.0 version, for example-- it will not report it as higher than 5.1.2600.0. – Paul Williams Sep 01 '15 at 13:37
2

Take a look at this article by Microsoft How to determine the operating system service pack level in Visual Basic .NET or in Visual Basic 2005

Christian Witts
  • 11,375
  • 1
  • 33
  • 46