Automate a vbscript by checking the OS version before running

Hi All,

I am trying to automate a script that I have to run on Windows 2000, XP and 7 (64bit). Currently I am asking for user input by using the case method. I was wondering if it is possible to automate this? I need the script to check what OS version it is and to run that part of the script.

The file structure of what I am installing is the same for Windows 2000 and XP. It is different for Windows 7. Please advice?
Vicki05Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vicki05Author Commented:
I got an error, but ended up using the following which worked. Still need to test on a Windows 2000 computer.

strComputer = "."
Set objShell = CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
Set colOSItems = objWMIService.ExecQuery("SELECT Caption FROM Win32_OperatingSystem")
For Each objItem In colOSItems
        strOS = objItem.Caption
Next
For Each objItem In colItems
        strName = objItem.Name
        strManufacturer = objItem.Manufacturer
        strSystemType = objItem.SystemType
        strModel = objItem.Model
Next  

If InStr(strOS, "XP") > 0 Then
     Msgbox "XP"

ElseIf InStr(strOS, "2000") > 0 Then  
          Msgbox "2000"


 
ElseIf InStr(strOS, "Windows 7") > 0 Then  
          Msgbox "7"
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
netcmhCommented:
Great! Good luck on the 2000.
0
Vicki05Author Commented:
I found this solution and it works great. Still working on sleep time for Windows 2000.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Operating Systems

From novice to tech pro — start learning today.