How To Determine The OS Type In A Logon Script
Last Updated: 02 Mar 2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*** PLEASE NOTE: Link(s), If Provided, May Be Wrapped ***
Often times, you need to process a logon script differently
depending on the OS in question. If you're only looking to
distinguish between "NT/Win2K" and "EVERYTHING ELSE", then
the following code snippet will be adequate:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:OSCheck
IF "%OS%"=="Windows_NT" GOTO :NT-Win2K
rem Your OS is neither NT nor Win2K
:OtherOS
**** do NON-NT things here ****
GOTO :Common
rem Your OS is NT or Win2K
:NT-Win2K
**** do NT things here ****
:Common
**** do common things here ****
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another basic option to parse the VER command in Windows NT
and later, via the command shell. This will result in the
following information for various editions of Windows:
• Windows 2000 ........... Version 5.0.2195
• Windows XP ............. Version 5.1.2600
• Windows 2003 ........... Version 5.2.3790
OPTION #1 -- Get OS Version for NT and Higher
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FOR /F "TOKENS=2 DELIMS=[]" %%O IN ('VER') DO SET @OSVER=%%O
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
OPTION #2 -- Get OS Version for NT and Higher
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FOR /F "TOKENS=2 DELIMS=[]" %%V IN ('VER') DO (
FOR /F "TOKENS=2-4 DELIMS=. " %%O IN ('ECHO %%V') DO (
SET @OSVER=%%O.%%P.%%Q
SET @OSMAJ=%%O
SET @OSMIN=%%P
SET @OSBUILD=%%Q
)
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GRANULAR INFORMATION
If you need more granular information than that, (for
example, NT Servers vs NT Workstations), then you
should make use of one of the following utilities:
• VER .................... Native Utility -- All Windows Versions
• SYSTEMINFO ............. Native Utility -- WinXP
• GETTYPE ................ Resource Kit -- Win2K
• CMDINFO ................ http://www.savilltech.com/cmdinfo.html
• GETTYPE ................ http://support.microsoft.com/?KBID=190899
• NTinfo ................. http://www.admwin.com/
• psInfo ................. http://www.sysinternals.com/ntw2k/freeware/psinfo.shtml
• Win9xNTVer ............. http://www.walbeehm.com/mrcode.html#Win9xNTVer
• WININFO ................ http://www.savilltech.com/wininfo.html
• XQGetOSVer ............. http://www.xteq.com/products/geto/
WHITEPAPERS & TECH DOCUMENTS
• http://www.nncron.ru/help/EN/commands/os.htm
RELATED SCRIPTS (ALSO IN THIS ARCHIVE)
• http://KB.UltraTech-llc.com/Scripts/?File=OSType-A.BAT
• http://KB.UltraTech-llc.com/Scripts/?File=OSType-B.BAT
• http://KB.UltraTech-llc.com/Scripts/?File=Logon.BAT
• http://KB.UltraTech-llc.com/Scripts/?File=SetDrive.BAT
• http://KB.UltraTech-llc.com/Scripts/?File=SwapShares.BAT
RELATED TOPICS (ALSO IN THIS ARCHIVE)
• http://KB.UltraTech-llc.com/?File=NTVer.TXT
• http://KB.UltraTech-llc.com/?File=SysInfo.TXT
• http://KB.UltraTech-llc.com/?File=HomeDirs.TXT
• http://KB.UltraTech-llc.com/?File=MapDrive.TXT
• http://KB.UltraTech-llc.com/?File=ResKit.TXT
• http://KB.UltraTech-llc.com/?File=Utils.TXT
• http://KB.UltraTech-llc.com/?File=Scripting.TXT