Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to execute only on server OS 2

Status
Not open for further replies.

jdeane

IS-IT--Management
Sep 21, 2001
229
GB
it has been a while since I scripted any vbs but is there a means to ensure that a script will only execute on a server OS and not on a work station?

Thank you

Jon
 
As an example this takes the computer name on the command line and displays the OS version. After you query the version you can execute a Wscript.Quit for all but approved version strings.
Code:
computerName = Wscript.Arguments(0)

'----- Connect to computer and query drives
Set WMIService = GetObject("winmgmts:\\" & computerName & "\root\CIMV2") 

Set OSInfo = WMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

For Each OSItem in OSInfo
	fullVer = OSItem.Version
	majorVer = Left(OSItem.Version,3)
Next

Wscript.Echo "Major Version: " & majorVer & "   Full Version: " & fullVer

For XP you will see a major version of "5.1", Server 2003 will report "5.2". I don't know what Server 2008 will report. This will give you a start though.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
Our Server 2008 reports -
Major version: 6, Full Version: 6.0.6001

David.
 
Hmmm. I think Vista also reports 6.0. You may need to look at the full version to distinguish between the two.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
>...on a server OS and not on a work station
A server os can be installed on a workstation. It should be differentiateing in a more generic way the computer's role. Use the domainrole attribute exposed by the win32_computersystem class may be a better approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top