1

Does anyone have sample VBS code that creates a switch statement based on whether the client OS is Windows XP, 2000, NT, or 95?

2 Answers 2

3

This will give you the OS version:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    Wscript.Echo objOperatingSystem.Caption & " " & _
        objOperatingSystem.Version
Next

From this you can setup a Select Case Statement (VB syntax for a switch) and check the .Version against the Case "OS" where "OS" is the various types returned from .Version

Here's a sample of doing exactly that:

http://www.computerperformance.co.uk/ezine/ezine52.htm

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the edit Eduardo. Syntax looks much better now that it's all in the code block. :)
0

VBScript samples to retrieve Operating System Version information

http://www.activexperts.com/activmonitor/windowsmanagement/scripts/operatingsystem/version/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.