How to display OS Name in short name ?

E

engteng

How to display OS Name in short Name eg Win Vista SP1
Win XP
2003 SP2


Regards,
Tee ET
 
K

kimiraikkonen

How to display OS Name in short Name eg Win Vista SP1
Win XP
2003 SP2

Regards,
Tee ET

For XP,
You can you can manually define them in nested if-then blocks like the
following:

' --------Begin Code-----------

'Check and get full OSName
If My.Computer.Info.OSFullName.ToString = _
"Microsoft Windows XP Professional" Then
'Check and get service pack version
If Environment.OSVersion.ServicePack.ToString = _
"Service Pack 2" Then
MsgBox("Win XP SP2")
End If
ElseIf My.Computer.Info.OSFullName.ToString = _
"Microsoft Windows XP Professional" Then
'Assuming no or other Service Packs are installed
' plus only XP is installed
MsgBox("Win XP")
End If

'.....Reproduce same for Vista

' ------End Code-----------

Or you can use substring method to fit OSName/SPVersion output to what
you desire.


Hope this helps,

Onur Güzel
 
S

Stanimir Stoyanov

My way of getting a proper OS version string + SP number:

Function GetOSVersion() As String
Dim os As OperatingSystem = Environment.OSVersion
Dim displayName As String = "Win "
Dim origSp As String = os.ServicePack

If String.IsNullOrEmpty(origSp) Then
origSp = ""
Else
origSp = origSp.Replace("Service Pack", "").Trim()
End If

Select Case os.Platform
Case PlatformID.Win32Windows ' 95, 98, ME
Select Case os.Version.Minor
Case 0 : displayName &= "95"
Case 10
displayName &= "98"

If os.Version.Revision.ToString() = "2222A" Then
displayName &= " SE"
End If
Case 90 : displayName &= "ME"
End Select

Case PlatformID.Win32NT
Select Case os.Version.Major
Case 3 : displayName &= "NT 3.51"
Case 4 : displayName &= "NT 4"
Case 5
Select Case os.Version.Minor
Case 0 : displayName &= "2000"
Case 1 : displayName &= "XP"
Case 2 : displayName &= "2003"
End Select
Case 6 : displayName &= "Vista"
Case 7 : displayName &= "7"

End Select
End Select

If origSp.Length > 0 AndAlso origSp <> "0" Then
displayName &= " SP" & origSp
End If

Return displayName.Trim()
End Function

Best Regards,
Stanimir Stoyanov | www.stoyanoff.info
 
H

Herfried K. Wagner [MVP]

engteng said:
How to display OS Name in short Name eg Win Vista SP1
Win XP
2003 SP2

These short names are not defined by Microsoft. Microsoft uses (for legal
reasons, I assume) only the complete names of their products.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top