Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect version of windows using batch file

Status
Not open for further replies.

mizzy

IS-IT--Management
Jun 28, 2001
277
AU

Hi there,

I want to know if it is possible to detect what version of Windows is being run on a PC by using a batch file program.

Then based on the result I will run a certain program.

Thanks & regards,

 
I'm not sure about earlier versions but, in 2000 and in XP if you type "ver" at a commandline it spits back which version of windows you are running...
 
@echo off
cls
echo.
::
ver | find "Windows XP" >nul
if not errorlevel 1 goto XP
::
ver | find "Windows 2000" >nul
if not errorlevel 1 goto 2K
::
ver | find "Windows NT" >nul
if not errorlevel 1 goto NT
::
ver | find "Windows ME" >nul
if not errorlevel 1 goto ME
::
ver | find "Windows 98" >nul
if not errorlevel 1 goto 98
::
ver | find "Windows 95" >nul
if not errorlevel 1 goto 95
::
ver | find "OEM Service Release" >nul
if not errorlevel 1 goto OEM
::
ver | find "MS-DOS" >nul
if not errorlevel 1 goto DOS
::
echo OS version not found...
goto end


:XP
echo OS is Windows XP ...
goto end

:2K
echo OS is Windows 2K ...
goto end

:NT
echo OS is Windows NT ...
goto end

:ME
echo OS is Windows ME ...
goto end

:98
echo OS is Windows 98 ...
goto end

:95
echo OS is Windows 95 ...
goto end

:OEM
echo OS is Windows OSR ...
goto end

:DOS
echo OS is MS-DOS mode ...


:end
echo.
::


In the above you can eliminate whatever version test
you don't need and their corresponding labels...
Then replace those Echo commands with
your commands for the correct OS ...
You can also rearrange the Ver
commands to test the OS in
whatever order preferred.

Here's a table showing the information returned from the
Ver command under the various MS operating systems:

MS-DOS Version 6.22
Windows NT Version 4.0
Windows 95 [Version 4.00.950]
Windows 95 [Version 4.00.1111]
Windows 98 [Version 4.10.1998]
Windows 98 [Version 4.10.2222]
Windows Millennium [Version 4.90.3000]
Microsoft Windows XP [Version 5.1.2600]
Microsoft Windows 2000 [Version 5.00.2195]

Source: from rin1010's comments here:
 


Hey! thanks very much ,
Been out of the office for a few weeks.

Regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top