Identify Different OS's in DOS

Status
Not open for further replies.

bla!!

Daemon Poster
Messages
1,118
Location
/usr/root/mn/us
Hi, I'm trying to write a batch file that will execute different commands depending on what OS it's run on.

Can anyone help me with a way to identify the OS's.

In DOS you can type ver to get what OS version it is, but how would you compare that to say a string or a value?

Here's the basics of what I want to do.

IF OSVER == WinXP GOTO ONE
IF OSVER == Win2k GOTO TWO
IF OSVER == WinNT GOTO THREE
GOTO END
:ONE
execute registry entry for XP
GOTO END
:TWO
execute registry entry for 2k
GOTO END
:THREE
execute registry entry for NT4.0
:END
PAUSE

I found a way through novell, but not all users have novell logons, so I was wondering if there was a variable or a way to transfer the value of "ver" into a string so I can compare it to something else.
 
Compare the end of file character. I know they differ from OS to OS (how i don't remeber exactly). But if you are doing it from Windows version to Windows version, I not 100% sure it will be different. I know that Windows 95-ME use the FAT32 file system and XP and NT (i think) use the NTFS file system which means the eof should be different.
 
Yup, only downside is that I need to distinguish between XP, 2k and NT4.0

For each of these if you do ECHO %os% you get Windows_NT
The only command I could find that identified each OS is ver, but I can't figure out how to use it as a comparison operand.
 
For anyone who's interested, I found a snipet on like page 30 of a google search. Here's how I was able to detect the OS.

@ECHO OFF
PAUSE

set OS=Unknown
ver | find /i "Windows XP" > nul
if not ErrorLevel 1 set OS=WinXP

ver | find /i "Windows 2000" > nul
if not ErrorLevel 1 set OS=Wink2

ECHO %OS%

IF %OS% == WinXP GOTO ONE
IF %OS% == Win2k GOTO TWO

This will work for all version of Windows past 95 I believe.
 
Status
Not open for further replies.
Back
Top Bottom