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
OS
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]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.