I would like to know how to detect if a persons operating system is Windows 7, I'm a bit new and have no idea how to do this. Please let me know if it is possible and the code to do it.
Asked
Active
Viewed 2.3k times
6
-
you tagged this as VB. Did you mean vb.net or is this in a vbscript, or perhaps in VBA (Office macros)? – Conrad Frix Jul 02 '11 at 05:04
4 Answers
5
See the Environment.OSVersion
property on MSDN. It is a static property that returns an OperatingSystem
object, which has a Version
property and you can just check the Major
and Minor
version numbers to see if it is 6.1 (Windows 7 is actually version 6.1).
Dim osVer As Version = Environment.OSVersion.Version
If osVer.Major = 6 And osVer.Minor = 1 Then
Console.WriteLine("win7!!")
End If

Matt
- 4,318
- 1
- 27
- 28
3
It's easy to use My.Computer.Info.OSFullName
.
you need to set up the app.manifest
file to get the correct version number. even System.Environment.OSVersion.ToString() '
not gives the correct version if you have not been set the app.manifest
Console.WriteLine(My.Computer.Info.OSFullName)
Console.WriteLine(My.Computer.Info.OSVersion)
Console.WriteLine(My.Computer.Info.OSPlatform)
Output:
Microsoft Windows 10 Pro
10.0.18362.0
Win32NT

Harsha
- 549
- 4
- 10
2
I'm guessing since you're a bit new that you're actually using VB.NET rather than classic VB 6.
In VB.NET, you can use:
Dim osVersion As String = System.Environment.OSVersion.ToString()

Justin Niessner
- 242,243
- 40
- 408
- 536
0
I would use
My.Computer.Info.OSFullName

Donald Duck
- 8,409
- 22
- 75
- 99

CoolCoder123
- 88
- 1
- 7
-
3While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Donald Duck Nov 26 '20 at 20:40