WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Determine Windows Vista, 2008 and 7 Version Information

 Keywords: GetProductInfo Get Product Info Vista Win2008 Win7

This script can determine the Windows vista / Windows Server 2008/ Windows 7 version (enterprise,Ultimate,Standard Server etc.) The script uses a dllcall found on msdn.

;-------------------------------------------------------------------------;
; Author : Frank Thomas
; Revision : 2009/08/09
; Windows 7 & Windows 2008 R2 update
;-------------------------------------------------------------------------;

sSystemType = WinVersion(9)
Switch sSystemType
    Case 1
        _SystemType = "Workstation"
        Break
    Case 2
        _SystemType = "Domain Controller"
        Break
    Case 3
        _SystemType = "Server"
        Break
EndSwitch

If WinMetrics(-4) == 4
    If WinVersion( @MAJOR) == 4
        _OSPlatform = "WinNT"
    EndIf
    If WinVersion( @MAJOR) == 5
        _OSPlatform = "WinNT50"
    EndIf
    If WinVersion( @MAJOR) == 6
        _OSPlatform = "WinNT60"
    EndIf
EndIf

_OSVerStr = _OSPlatform
_OSVerNum = StrCat( WinVersion(1), ".", WinVersion(0))
_OSVerBld = WinVersion(2)
_OSVerCsd = WinVersion(3)
_OSVerStrLong = ""
_sOSType = ""

If _OSPlatform == "WinNT60"
    _OSVerStr = "Windows Vista"
    _OSVerNum = StrCat( WinVersion(1), ".", WinVersion(0))
    _OSVerBld = WinVersion(2)
    _OSVerCsd = WinVersion(3)
    If WinVersion(1) == "6" && WinVersion(0) == "0"
        GoSub GetWinNT6Type
        If _SystemType == "Workstation"
            _OSVerStr  = "Windows Vista"
        Else
            _OSVerStr  = "Windows Server 2008"
        EndIf
        _OSVerStrLong  = StrCat(_OSVerStr," ",_sOSType)
    Else
        If WinVersion(1) == "6" && WinVersion(0) == "1"
           GoSub GetWinNT6Type
            If _SystemType == "Workstation"
                _OSVerStr  = "Windows 7"
            Else
                _OSVerStr  = "Windows Server 2008 R2"
            EndIf
            _OSVerStrLong  = StrCat(_OSVerStr," ",_sOSType)
        EndIf
    EndIf
    _OSVerStrLong = StrCat(_OSVerStr," ",_sOSType)
EndIf

If _OSVerCsd == "" Then _OSVerCsd = "No Service Pack"

Message(_OSVerStrLong,StrCat("OS",@TAB,@TAB,_OSVerStr,@CRLF,"Type",@TAB,@TAB,_sOSType,@CRLF,"OS Version Nr",@TAB,_OSVerNum,@CRLF,"Build",@TAB,@TAB,_OSVerBld,@CRLF,"Service Pack",@TAB,_OSVerCsd))

Return

:GetWinNT6Type

;BOOL WINAPI GetProductInfo(
;  __in   DWORD dwOSMajorVersion,
;  __in   DWORD dwOSMinorVersion,
;  __in   DWORD dwSpMajorVersion,
;  __in   DWORD dwSpMinorVersion,
;  __out  PDWORD pdwReturnedProductType
;);

;Allocate buffer
hdlBB = BinaryAlloc (4)
DllCall ("KERNEL32.DLL", LPSTR:'GetProductInfo', long:6, long:0, long:0, long:0, lpbinary:hdlBB)
intProductType = BinaryPeek4 (hdlBB, 0)
BinaryFree (hdlBB)
Switch intProductType
    Case 0
        _sOSType = "Undefined"
        Break
    Case 1
        _sOSType = "Ultimate"
        Break
    Case 2
        _sOSType = "Home Basic"
        Break
    Case 3
        _sOSType = "Home Basic Premium"
        Break
    Case 4
        _sOSType = "Enterprise"
        Break
    Case 5
        _sOSType = "Home Basic N"
        Break
    Case 6
        _sOSType = "Business"
        Break
    Case 7
        _sOSType = "Standard Server (full installation)"
        Break
    Case 8
        _sOSType = "Datacenter Server (full installation)"
        Break
    Case 9
        _sOSType = "Small Business Server"
        Break
    Case 10
        _sOSType = "Enterprise Server (full installation)"
        Break
    Case 11
        _sOSType = "Starter"
        Break
    Case 12
        _sOSType = "Datacenter Server (core installation)"
        Break
    Case 13
        _sOSType = "Standard Server (core installation)"
        Break
    Case 14
        _sOSType = "Enterprise Server (core installation)"
        Break
    Case 15
        _sOSType = "Enterprise Server for Itanium-Based Systems"
        Break
    Case 16
        _sOSType = "Business N"
        Break
    Case 17
        _sOSType = "Web Server (full installation)"
        Break
    Case 18
        _sOSType = "HPC Edition"
        Break
    Case 19
        _sOSType = "Home Server"
        Break
    Case 20
        _sOSType = "Storage Express Server"
        Break
    Case 21
        _sOSType = "Storage Standard Server"
        Break
    Case 22
        _sOSType = "Storage Workgroup Server"
        Break
    Case 23
        _sOSType = "Storage Enterprise Server"
        Break
    Case 24
        _sOSType = "Windows Server 2008 for Windows Essential Server Solutions"
        Break
    Case 25
        _sOSType = "Small Business Server Premium Edition"
        Break
    Case 26
        _sOSType = "Home Premium N"
        Break
    Case 27
        _sOSType = "Enterprise N"
        Break
    Case 28
        _sOSType = "Ulitmate N"
        Break
    Case 29
        _sOSType = "Web Server (core installation)"
        Break
    Case 30
        _sOSType = "Windows Essential Business Server Management Server"
        Break
    Case 31
        _sOSType = "Windows Essential Business Server Security Server"
        Break
    Case 32
        _sOSType = "Windows Essential Business Server Messaging Server"
        Break
    Case 33
        _sOSType = "Server Foundation"
        Break
    Case 35
        _sOSType = "Windows Server 2008 without Hyper-V for Windows Essential Server Solutions"
        Break
    Case 36
        _sOSType = "Server Standard without Hyper-V (full installation)"
        Break
    Case 37
        _sOSType = "Server Datacenter without Hyper-V (full installation)"
        Break
    Case 38
        _sOSType = "Server Enterprise without Hyper-V (full installation)"
        Break
    Case 39
        _sOSType = "Server Datacenter without Hyper-V (core installation)"
        Break
    Case 40
        _sOSType = "Server Standard without Hyper-V (core installation)"
        Break
    Case 41
        _sOSType = "Server Enterprise without Hyper-V (core installation)"
        Break
    Case 42
        _sOSType = "Microsoft Hyper-V Server"
        Break
    Case 47
        _sOSType = "Starter N"
        Break
    Case 48
        _sOSType = "Professional"
        Break
    Case 49
        _sOSType = "Professional N"
        Break
    Case 66
        _sOSType = "Starter E"
        Break
    Case 67
        _sOSType = "Home Basic E"
        Break
    Case 68
        _sOSType = "Home Premium E"
        Break
    Case 69
        _sOSType = "Professional E"
        Break
    Case 70
        _sOSType = "Enterprise E"
        Break
    Case 71
        _sOSType = "Ultimate E"
        Break
    Case 2882382797
        _sOSType = "Unlicensed"
        Break
EndSwitch
Return

Article ID:   W17466
File Created: 2009:08:06:09:40:14
Last Updated: 2009:08:06:09:40:14