Login | |
|
 |
RE: Don't run script if OS = Server OS - 7/11/2006 1:55:46 AM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
somthing like this? 'Check if this is a Server. If this is a server quit Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48) For Each objItem in colItems If InStr(1,objItem.Caption,"Server") Then Wscript.Quit Next
|
|
| |
|
|
|
 |
RE: Don't run script if OS = Server OS - 7/12/2006 12:58:35 AM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
here we go strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48) For Each objItem in colItems If InStr(1,objItem.Caption,"98") Then Wscript.Quit If InStr(1,objItem.Caption,"XP") Then Wscript.Quit If InStr(1,objItem.Caption,"2000") Then Wscript.Quit If InStr(1,objItem.Caption,"2003") Then Wscript.Quit Next
< Message edited by gdewrance -- 7/12/2006 1:04:47 AM >
|
|
| |
|
|
|
 |
RE: Don't run script if OS = Server OS - 7/12/2006 1:09:41 AM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
yes dont forget the first post "server" this was just to let you know of more ways and the strcomputer="."
|
|
| |
|
|
|
 |
RE: Don't run script if OS = Server OS - 7/12/2006 1:14:40 AM
|
|
 |
|
| |
KnightBird
Posts: 27
Score: 0
Joined: 7/11/2006
Status: offline
|
OK when the script gets to line If InStr(1,objItem.Caption,"2000") Then Wscript.Quit I get the message: Script: Logon.vbs Line: 12 Character: 1 Error: Object Required: 'objItem' Code: 800A01A8 Now what did i break? Here is the complete code.. ---------------------------- Set wshNetwork = CreateObject("WScript.Network") 'Check if this is a Server. If this is a server quit strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48) For Each objItem in colItems If InStr(1,objItem.Caption,"98") Then OSVer = "98" If InStr(1,objItem.Caption,"XP") Then OSVer = "XP" If InStr(1,objItem.Caption,"2000") Then OSVer = "2000" If InStr(1,objItem.Caption,"2003") Then OSVer = "2003" Next 'If you would like the script not to run based on OS add If InStr(1,objItem.Caption,"2000") Then Wscript.Quit If InStr(1,objItem.Caption,"2003") Then Wscript.Quit 'display the OS ver 'WScript.Echo OSVer ' Standard Mappings wshNetwork.MapNetworkDrive "H:","\\servername\usershare\" & wshNetwork.UserName 'End Standard Mappings Set ADSysInfo = CreateObject("ADSystemInfo") Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName) strGroups = LCase(Join(CurrentUser.MemberOf)) 'If InStr(strGroups, CLEIT) Then 'If InStr(strGroups, "cn=it") Then If InStr(strGroups, IT) Then wshNetwork.MapNetworkDrive "S:","\\servername\shareddata" wshNetwork.AddWindowsPrinterConnection "\\servername\printer" End If
|
|
| |
|
|
|
 |
RE: Don't run script if OS = Server OS - 7/12/2006 1:32:44 AM
|
|
 |
|
| |
KnightBird
Posts: 27
Score: 0
Joined: 7/11/2006
Status: offline
|
I think i solved it..... what do you think? ------------------------------ Set wshNetwork = CreateObject("WScript.Network") 'Check if this is a Server. If this is a server quit strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48) For Each objItem in colItems If InStr(1,objItem.Caption,"98") Then OSVer = "98" If InStr(1,objItem.Caption,"XP") Then OSVer = "XP" If InStr(1,objItem.Caption,"2000") Then OSVer = "2000" If InStr(1,objItem.Caption,"2003") Then OSVer = "2003" Next 'If you would like the script not to run based on OS add If OSVER = "2000" Then Wscript.Quit If OSVER = "2003" Then Wscript.Quit ----------------------- This seems to be working on servers, not running and on XP workstations. But there will be windows 2000 workstations, so how do i get around that?
|
|
| |
|
|
|
 |
RE: Don't run script if OS = Server OS - 7/12/2006 1:32:52 AM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
this is what I meant the first time Set wshNetwork = CreateObject("WScript.Network") 'Check if this is a Server. If this is a server quit strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48) For Each objItem in colItems If InStr(1,objItem.Caption,"98") Then Wscript.Quit If InStr(1,objItem.Caption,"XP") Then Wscript.Quit If InStr(1,objItem.Caption,"Server") Then Wscript.Quit If InStr(1,objItem.Caption,"2003") Then Wscript.Quit Next Take a look at Marks script http://www.tek-tips.com/faqs.cfm?fid=5798
< Message edited by gdewrance -- 7/12/2006 1:40:23 AM >
|
|
| |
|
|
|
 |
RE: Don't run script if OS = Server OS - 7/17/2006 8:26:57 AM
|
|
 |
|
| |
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
|
I dont have a 64bit version of windows here at work to test it out, but I'm curious to see if the caption information from the Win32_OperatingSystem WMI class would have it. If someone that has a 64bit version of windows could test it out with this script (taken from the script center): Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime") 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 "Boot Device: " & objOperatingSystem.BootDevice Wscript.Echo "Build Number: " & objOperatingSystem.BuildNumber Wscript.Echo "Build Type: " & objOperatingSystem.BuildType Wscript.Echo "Caption: " & objOperatingSystem.Caption Wscript.Echo "Code Set: " & objOperatingSystem.CodeSet Wscript.Echo "Country Code: " & objOperatingSystem.CountryCode Wscript.Echo "Debug: " & objOperatingSystem.Debug Wscript.Echo "Encryption Level: " & objOperatingSystem.EncryptionLevel dtmConvertedDate.Value = objOperatingSystem.InstallDate dtmInstallDate = dtmConvertedDate.GetVarDate Wscript.Echo "Install Date: " & dtmInstallDate Wscript.Echo "Licensed Users: " & _ objOperatingSystem.NumberOfLicensedUsers Wscript.Echo "Organization: " & objOperatingSystem.Organization Wscript.Echo "OS Language: " & objOperatingSystem.OSLanguage Wscript.Echo "OS Product Suite: " & objOperatingSystem.OSProductSuite Wscript.Echo "OS Type: " & objOperatingSystem.OSType Wscript.Echo "Primary: " & objOperatingSystem.Primary Wscript.Echo "Registered User: " & objOperatingSystem.RegisteredUser Wscript.Echo "Serial Number: " & objOperatingSystem.SerialNumber Wscript.Echo "Version: " & objOperatingSystem.Version Next
_____________________________
Have you searched here ? VBScript Fundamentals My Site
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|