fpschultze - Howto - Batch Howto - How To Determine The Operating System?

fpschultze

Frank-Peter Schultze's Scripting Site

WebRing
Login Consultants BlogRing
Previous Site : Random Site : Next Site : List Sites
Powered by WebRingo
Main Menu
Site Search
License
Creative Commons License
Cool Companies
Login Consultants
Immidio | Shortcuts For Sharp Minds
My PowerShell IDE is PowerGUI
SmartFAQ is developed by The SmartFactory (http://www.smartfactory.ca), a division of InBox Solutions (http://www.inboxsolutions.net)

How To Determine The Operating System?
Requested and Answered by Frank-Peter Schultze [webmaster] on 06-Sep-2005 17:40 (14791 reads)
The VER command displays the operating system version, for example:

C:\TEMP>ver

Microsoft Windows XP [Version 5.1.2600]

C:\TEMP>_

If you need to check the OS in a batch file you just have to examine VER's output with FIND or FINDSTR. The code below shows how to check if a batch file runs on Windows 9x or Windows NT/2K/XP:

 @Echo Off
Ver | Find "95" >NUL
If Not ErrorLevel 1 Goto Win9x
Ver | Find "98" >NUL
If Not ErrorLevel 1 Goto Win9x
Ver | Find "Millennium" >NUL
If Not ErrorLevel 1 Goto Win9x
Ver | Find "NT" >NUL
If Not ErrorLevel 1 Goto WinNT
Ver | Find "2000" >NUL
If Not ErrorLevel 1 Goto WinNT
Ver | Find "XP" >NUL
If Not ErrorLevel 1 Goto WinNT
Echo Unsupported Operating System
Goto :EOF
:Win9x
::Windows 9x/ME code
:
:
Goto :EOF
:WinNT
::Windows NT code
:
:
Goto :EOF


 

© 2000-2006 mail | Powered by XOOPS 2.0.13.1 © 2001-2005 The XOOPS Project