DOS Batch file help -- Determining Windows Server or Client OS

Posted by: tfabris

DOS Batch file help -- Determining Windows Server or Client OS - 12/10/2009 16:49

ver | find "5.2." > NUL
if NOT ERRORLEVEL 1 set MyWindowsVer=Server2k3
ver | find "6.1." > NUL
if NOT ERRORLEVEL 1 set MyWindowsVer=Win7
ver | find "6.0." > NUL
if NOT ERRORLEVEL 1 set MyWindowsVer=Vista
ver | find "5.1." > NUL
if NOT ERRORLEVEL 1 set MyWindowsVer=XP

Only problem is that 6.0 counts for both Vista and for Server2008. How to differentiate the two from within a DOS batch file?
Posted by: tman

Re: DOS Batch file help -- Determining Windows Server or Client OS - 12/10/2009 17:11

systeminfo?

Code:
OS Name:                   Microsoft Windows 7 Ultimate
Posted by: tfabris

Re: DOS Batch file help -- Determining Windows Server or Client OS - 12/10/2009 17:30

Hee. It works but it's weird.

C:\Users\Username>systeminfo
Host Name: HOSTNAME
OS Name: Microsoftr Windows Serverr 2008 Standard
OS Version: 6.0.6001 Service Pack 1 Build 6001

Note the extra "r"s

heh.
Posted by: tman

Re: DOS Batch file help -- Determining Windows Server or Client OS - 12/10/2009 17:49

Originally Posted By: tfabris
Hee. It works but it's weird.

C:\Users\Username>systeminfo
Host Name: HOSTNAME
OS Name: Microsoftr Windows Serverr 2008 Standard
OS Version: 6.0.6001 Service Pack 1 Build 6001

Note the extra "r"s

heh.

Hmm... Maybe its the registered trademark symbol? I don't get it on W7.
Posted by: tfabris

Re: DOS Batch file help -- Determining Windows Server or Client OS - 12/10/2009 19:41

It's definitely the registered trademark symbol, and yes, it doesn't happen in Vista or Win7.

I'm not sure if it's an R1 or R2 or SP1 etc thing or not, I don't have that many Server 2008 boxes to test against. I just thought it was funny.
Posted by: drakino

Re: DOS Batch file help -- Determining Windows Server or Client OS - 12/10/2009 20:20

Also keep in mind 5.2 is Windows XP 64 bit.
Posted by: tfabris

Re: DOS Batch file help -- Determining Windows Server or Client OS - 12/10/2009 21:16

Thanks, that's nice to know.
Posted by: Roger

Re: DOS Batch file help -- Determining Windows Server or Client OS - 13/10/2009 05:51

Code:
C:\>reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    EditionID    REG_SZ    ServerStandard


On Windows Server 2008 Standard Edition SP2. Windows 7 RC just says "Ultimate".
Posted by: Roger

Re: DOS Batch file help -- Determining Windows Server or Client OS - 13/10/2009 05:52

Originally Posted By: drakino
Also keep in mind 5.2 is Windows XP 64 bit.


Yeah, Windows XP 64 is basically just Windows 2003 SP2. That was when they got the two streams back together, so that Windows Vista is Windows 2008 and Windows 7 is Windows 2008 R2.