Jump to content

Windows Version


Geoff KB
 Share

Recommended Posts

I think I might have misunderstood your question... but you could go to start > run and type cmd then OK

That will bring up the command prompt. Just type ver and hit enter, your windows version will be displayed

Or you could follow the instructions here, but that involves a registry edit so please make sure you back up your registry before making any changes.

Or there is BGinfo from Sysinternals... that can put selected information on the desktop if you wish :)

Link to comment
Share on other sites

Thanks but that wasn't what I meant.

I have a spreadsheet which will be used by people running various versions of Windows. I'd like my error message box to indicate which version of windows they have, so we can identify errors more easily.

I'm using val(Applications.version) for the Excel version, I expected Val(osversion.version) to return the Windows version, but it doesn't.

Any other ideas much appreciated.

Geoff

Link to comment
Share on other sites

These are just ideas because I don't know much about excel but here is what I seen after a quick look on google. I didn't seem that you could do it unless you use a macro. Here are code examples I got from two different sites.

'Deklarationsbereich
Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(ByRef lpVersionInformation As OSVERSIONINFO) As Long

'Codemodul
Sub GetWindowsVersion()
Dim myOS As OSVERSIONINFO
Dim lngResult As Long
Dim strVersion As String
myOS.dwOSVersionInfoSize = Len(myOS)
lngResult = GetVersionEx(myOS)
If myOS.dwPlatformId = 0 Then
strVersion = "Windows"
ElseIf myOS.dwPlatformId = 1 Then
strVersion = "Windows (95, 98 oder ME)"
ElseIf myOS.dwPlatformId = 2 Then
strVersion = "Windows (NT, 2000, XP oder 2003)"
Else
strVersion = "Windows"
End If
MsgBox strVersion & vbCrLf & "Version " & myOS.dwMajorVersion & "." & _
myOS.dwMinorVersion & vbCrLf & "Build " & myOS.dwBuildNumber
End Sub

and

		Dim sAns As String

osInfo = System.Environment.OSVersion

With osInfo
Select Case .Platform
Case .Platform.Win32Windows
Select Case (.Version.Minor)
Case 0
sAns = "Windows 95"
Case 10
If .Version.Revision.ToString() = "2222A" Then
sAns = "Windows 98 Second Edition"
Else
sAns = "Windows 98"
End If
Case 90
sAns = "Windows Me"
End Select
Case .Platform.Win32NT
Select Case (.Version.Major)
Case 3
sAns = "Windows NT 3.51"
Case 4
sAns = "Windows NT 4.0"
Case 5
If .Version.Minor = 0 Then
sAns = "Windows 2000"
ElseIf .Version.Minor = 1 Then
sAns = "Windows XP"
ElseIf .Version.Minor = 2 Then
sAns = "Windows Server 2003"
Else 'Future version maybe update
'as needed
sAns = "Unknown Windows Version"
End If
End Select

End Select
End With

Return sAns
End Function

The second is VB. I don't know if you can use them but I thought they may help. goodluck

Link to comment
Share on other sites

You can use the following function. Modify it according to your requirement.

Function GetOS()

Dim strComputer, strWMIOS

strComputer = "."

On Error Resume Next

Dim objWmiService : Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\cimv2")

Dim strOsQuery : strOsQuery = "Select * from Win32_OperatingSystem"

Dim colOperatingSystems : Set colOperatingSystems = objWMIService.ExecQuery(strOsQuery)

Dim objOs

Dim strOsVer

For Each objOs in colOperatingSystems

strWmios = objOs.Caption & " " & objOs.Version

Next

Select Case True

Case InStr(strWmiOS, "2000 Server") > 1 : GetOS = "2KSRV"

Case InStr(strWmiOS, "2003, Standard") > 1 : GetOS = "2K3SRV"

Case InStr(strWmiOS, "2003, Enterprise") > 1 : GetOS = "2K3ENTSRV"

Case InStr(strWmiOS, "2000 Advanced Server") > 1 : GetOS = "2KADVSRV"

Case InStr(strWmiOS, "Windows NT") > 1 : GetOS = "NT4"

Case InStr(strWmiOS, "Windows 2000") > 1 : GetOS = "W2K"

Case InStr(strWmiOS, "Windows XP") > 1 : GetOS = "WXP"

Case Else : GetOS = "Unknown"

End Select

End Function

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.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy