Actually, you'd probably be better off replacing objOS.Name with objOS.Caption
Main Topics
Browse All TopicsHello everyone.
I require a batch logon script to detect the version of Windows OS. If it detects 2000 then it to goes to :Windows_2000, if it detects XP then it goes to :Windows_XP etc...
It needs to detect Windows 7 too. If it detects any other OS including 98/95 then it goes to :Unsupported_OS.
I've tried using 'VER | find' and it works but only for 2000 and XP. I've been unsuccessful in detecting the other versions.
Hope someone maybe able to help. Thanks very much!
BF
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
How about getting the os version using vb script then passing it to your main batch file. The attached code will do that and log the os into a file. Just change the directory and path to one of your own.
Then section at the bottom then passes the os version to a batch file for processing.
I have :
echo Hi %username% you os is %1
pause;
in vista2.bat using the %1 as the os passed from the vb script.
I can only code batch scripts and have very limited knowledge of VB Scripts.
I like the idea of passing the OS version to the batch script but the VB script needs to run from within a batch script first and then pass the version to %OSVersion%.
Also, can Windows 2000 and lower run VB Script? If not, how do you get it to detect those versions?
I still prefer the idea of using basic batch code otherwise I could be in the situation of not being able to successfully troubleshoot.
Thanks and appreciate your help thus far.
Lets look at this another way. It seems the older operating systems are the issue. How about a solution to filter them.
http://support.microsoft.c
Gettype.exe:
http://www.petri.co.il/dow
What you would need to do is save the script below as OS.vbs into the same folder as the batch file - for the example, I have used C:\Temp
Then in your batch file, place these 3 lines at the top:
@echo off
For /F "delims=" %%A in ('cscript //nologo c:\temp\OS.vbs') do Set OSVersion=%%A
echo %OSVersion%
What it should do is call the VBScript and the output will be stored in the %OSVersion% variable (it is also echoed to the screen, but you can remove that part)
Thank you very much.
djpazza - I will take a look at those links and code and see what I come up with.
Psy053 - Thanks for the code and advice - would you know which versions of Windows would 100% support this code? i.e. should it work on 2000, XP, Vista and 7?
I'm going to test the code with XP and Vista and see how I get on.
You both have been great - will update you shortly.
As a side note, you should still be able to use ver|find with newer versions of Windows. You just have to search on the version number which is listed instead of the name.
Using DOS
Firstly, set up your own variable on each machine. Either Autoexec.bat for DOS, Win95,98,ME or in Environment variables in 2K, XP, NT.
Something like OSVER="XP" or OSVER="98" etc
Then in a bacth file you can use
IF %OSVER%==XP GOTO xp
IF %OSVER%==98 GOTO 98
:xp
action.....
:98
Action
etc etc.
Hope that helps
Mark
A potentially simpler alternative is my OSTest.exe utility (http://www.westmesatech.c
Thank you so much to everyone who has helped. I am going to award points as fairly as possible. Obviously I cannot give to everyone but I really appreciate all of the help you have provided :)
I've checked out everyone's replies and it's taught me a great deal. The VB script and VER options are two of the main ways I will approach this.
Awarding Psy053, djpazza, and Shift-3.
Business Accounts
Answer for Membership
by: Psy053Posted on 2009-10-07 at 02:53:17ID: 25513556
Here is a VBSCript that will do it.
Select allOpen in new window