Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i want to run a program based on running operating system. can any one help me to find which operating system is running (95/98/NT/2000).

NT systems have the %OS% variable set by default to 'Windows_NT', and non-NT systems don't. So, if you just want to act depending if the OS is NT (Win NT4,2000,XP) or non-NT (Win9x, Dos 6.22), this will do it:
if "%OS%"=="Windows_NT" goto NT
echo This is non-NT!
goto eof
:NT
echo This is NT!
:eofHowever, if you need the batch file to act in a certain way for each OS, the best would be to check the return of the VER command.
Something like this would be required:
ver > %TEMP%.\T1.DAT
FIND "MS-DOS" < %TEMP%.\T1.DAT > nul
if not errorlevel=1 goto dos
FIND "Windows 95" < %TEMP%.\T1.DAT > nul
if not errorlevel=1 goto win95
FIND "Windows 98" < %TEMP%.\T1.DAT > nul
if not errorlevel=1 goto win98
FIND "Windows 2000" < %TEMP%.\T1.DAT > nul
if not errorlevel=1 goto win2000
FIND "Windows XP" < %TEMP%.\T1.DAT > nul
if not errorlevel=1 goto winXP
echo FATAL ERROR: could not detect your Operating System.
goto end
:: Here goes the part with the labels :dos
:: :win98 :win2000 etc
:end
if exist %TEMP%.\T1.DAT del %TEMP%.\T1.DATPS: I used a temporary file and all these lower-than characters intead of "VER|FIND..." because it's faster.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
help understanding dos &a...
|
getting someones ip in do...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |