ERCC (http://eriedel.info)

WinVersion


WinVersion determines version data of the current Windows system and returns selected data values. These values are returned with the program's exit code, in order to support their utilization within command files or scripts.
WinVersion can also display a complete version information.

Data output can be specified via WinVersion's call parameter, which can be one of the following:

Argument Exit Code
-base version class (see the following table),
e.g. 109 = Windows 8.1 64-bit
-bitness 1 = 32-bit, 2 = 64-bit
-build build number
-info displays version information (exit code 1)
-product product type value (see the description below)
-type 1 = Workstation, 2 = Domain Controller, 3 = Server
-version major and minor version numbers combined,
such as 63 = "6.3" = Windows 8.1 (see the following table)


WinVersion provides two different version numberings. For the argument -base, a numeration of the Windows version classes is returned. In many cases, this is the most important and sufficient information. 64-bitness adds 100 to this value.
With the argument -version you get the combination of major and minor version numbers, which are the actual values.

Windows Version Exit Code (-base)
64-bit OS: +100
Exit Code (-version)
Windows 11 11 100
Windows 10 10 100
Windows 8.1 9 63
Windows 8 8 62
Windows 7 7 61
Windows Vista 6 60
Windows XP 5 51 (64-bit: 52)
Windows 2000 4 50


The product type values returned by argument -product are the type codes of the API function GetProductInfo, which is availlable from Windows 6 (Vista/Server 2008) on. The large number of possible values is listed in the function description. Following are some typical values:

System Product Type / Exit Code
Home 101
Pro 48
Enterprise 4
Pro with Media Center 103
Server Standard 7


The exit code 0 principally signals a failure, especially version data not received. This value could also be returned as a product type for an "unknown product" (PRODUCT_UNDEFINED).


Usage

WinVersion is primarily intended to give the opportunity to differentiate between Windows versions within automated processes, for example to run version-specific programs (such as driver installation).

In a command file (.bat or .cmd), you can check the exit code using the IF ERRORLEVEL statement or the %ERRORLEVEL% variable.

winversion.exe -base
if errorlevel 100 (echo 64 Bit)
winversion.exe -version
if %errorlevel% EQU 63 (echo Windows 8.1)

In a WSH script, the exit code can be evaluated using the Exec and Run methods of the WScript.Shell object.

Dim ws, ec
Set ws = WScript.CreateObject("WScript.Shell")
ec = ws.Run("winversion.exe -base", , True)
WScript.Echo "Exit code = " & ec

For further information consult the descriptions available on these topics, in particular the MS documentation "Windows Command Reference" and "Microsoft Windows Script Technologies".

Remark:
Notice a peculiarity that exists in Windows Vista. The console process may permanently bind an external drive, for example a USB stick, if it was started from this drive. As a result, the system later refuses to release the drive again. This is a systemic error that can occur with any application.
You can avoid the problem by not using the console ("Command Prompt"). WinVersion is not a console program and can also be used in a script.


License, Notes

WinVersion is provided as freeware and "as is" without any warranty or liability. Please note that any usage of WinVersion is at your own risk.

WinVersion has been tested on different Systems from Windows 11 downwards to Windows XP. The program will probably not run on older systems (Windows 2000 and earlier).


Download, Installation

WinVersion is available as an executable program file  winversion.exe. Download this file and save it to a folder of your choice. The program doesn't require installation and has no external dependencies.

 

http://eriedel.info/en/files/winver/winversion.html


ERCC (http://eriedel.info)  2022   © Erhard Riedel Computer Consulting (ERCC)


link to info overview