Skip navigation

JSI Tip 4891. What operating system name are you running?


In previous tips on this site, we determined if a computer was running a Windows NT-based
operating system by using the if /i NOT "%OS%"

"Windows_NT" goto W9x

command.

We determined the Windows NT version using tip 4400.

To determine the textual version name of a computer's operating system, run TextVersion.bat, which returns the TVersion environment variable.

TextVersion.bat uses no parameters.

Example:

If I use TextVersion in a batch file, followed by the @echo %tversion% command, and run it on my Windows 2000 Professional workstation, it displays Microsoft Windows 2000.

TextVersion.bat contains:

@echo off
set tversion=
if /i NOT "%OS%""Windows_NT" goto end
for /f "Tokens=1 Delims=\[" %%a in ('ver') do set tversion=%%a##
set tversion=%tversion:  =%
set tversion=%tversion: ##=%
set tversion=%tversion:##=%
:end
To determine if you are running a non-Windows NT-based Operating system, we must use commands that work on all Windows operating systems. You could include the following in a batch file or logon script:
ver | find "Windows XP" >nul
if not errorlevel 1 goto WXP
ver | find "Windows 2000" >nul
if not errorlevel 1 goto W2000
ver | find "Windows NT" >nul
if not errorlevel 1 goto WNT
ver | find "Windows 98" >nul
if not errorlevel 1 goto W98
ver | find "Windows 95" >nul
if not errorlevel 1 goto W95
ver | find "Windows ME" >nul
if not errorlevel 1 goto WME
ver | find "OEM Service Release" >nul
if not errorlevel 1 goto WOEM
ver | find "MS-DOS" >nul
if not errorlevel 1 goto DOS
REM Unknown
echo ERROR - What are you running?
goto END
:WXP

goto end
:W2000

goto end
:WNT

goto end
:W98

goto end
:w95

goto end
:WME

goto end
:WOEM

goto end
:DOS

:end


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish