VER

Display the current operating system version.

Syntax

      VER

Use ver to find specific operating systems like this:

@Echo off
Setlocal
:: Get windows Version numbers
For /f "tokens=2 delims=[]" %%G in ('ver') Do (set _version=%%G) 

For /f "tokens=2,3,4 delims=. " %%G in ('echo %_version%') Do (set _major=%%G& set _minor=%%H& set _build=%%I) 

Echo Major version: %_major%  Minor Version: %_minor%.%_build%

if "%_major%"=="5" goto sub5
if "%_major%"=="6" goto sub6

Echo unsupported version
goto:eof

:sub5
::Winxp or 2003
if "%_minor%"=="2" goto sub_2003
Echo Windows XP [%PROCESSOR_ARCHITECTURE%]
goto:eof

:sub_2003
Echo Windows 2003 or XP 64 bit [%PROCESSOR_ARCHITECTURE%]
goto:eof

:sub6
if "%_minor%"=="1" goto sub7
Echo Windows Vista or Windows 2008 [%PROCESSOR_ARCHITECTURE%]
goto:eof

:sub7
Echo Windows 7 or Windows 2008 R2 [%PROCESSOR_ARCHITECTURE%]
goto:eof

Service Pack Version

This Batch script will give the Service Pack level.
Works for NT, Win2K or WinXP

32 bit or 64 bit process detection

The environment variable %PROCESSOR_ARCHITECTURE% holds the following possible values:

64-bit process: AMD64 or IA64
32-bit process or WOW64 (32bit Program on 64 bit OS): x86

If we are running WOW64 then %PROCESSOR_ARCHITEW6432% =AMD64

IF PROCESSOR_ARCHITECTURE == x86 AND
 PROCESSOR_ARCHITEW6432 NOT DEFINED THEN
// OS is 32bit
ELSE
// OS is 64bit
END IF

via David Wang

VER is an internal command.

“Always be a first-rate version of yourself, instead of a second-rate version of somebody else” ~ Judy Garland

Related:

Q190899 - How to Determine the OS Type in a Logon Script
WINVER.exe - Opens the GUI Version dialogue box (Help, About)
FILEVER - DLL version information (Resource Kit, XP Support tool)
Wikipedia - Microsoft Windows Version Numbers
Powershell: Get OS and Service pack
Equivalent bash command (Linux): uname -r - Print system information



Back to the Top

© Copyright SS64.com 1999-2013
Some rights reserved