Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Identify Different OS's in DOS
Closed Thread
Old 01-03-2005, 09:48 PM   #1 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default Identify Different OS's in DOS

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.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 01-03-2005, 11:09 PM   #2 (permalink)
 
Super Techie

Join Date: Jul 2004

Posts: 375

Nikkon

Default

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.
__________________
AMD 3800+ X2
Zalman CNPS7000B CPU Heatsink/Fan
ASUS A8N Premium
2 GB G. Skill DDR 400 (2 X 1 GB)
1 GB Ultra DDR 400 (2 X 512 GB)
eVGA 7800GT 256MB
120 GB seagate HD (7200RPM)
80 GB Seagate HD (7200RPM)
Sound Blaster Audigy 2 Platium ZS Sound Card
Logitec z5300 5.1 THX certified speaker
Medusa 5.1 Headphones
ATI TV turner card
DVD Drive
CD Burner Drive
Razer Copperhead Gaming mouse
Nikkon is offline  
Old 01-03-2005, 11:31 PM   #3 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

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.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 01-04-2005, 12:58 PM   #4 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

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.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On