From: MAN on 21 Apr 2010 06:09 I have an issue that I have been struggeling with for nealy a week now with out any success. The script is simple and is shown below. When the scrip is executed from a cmd prompt there is no issue. When the scrip is executed from within the Costum Action during installation the scrip fails on some PC's and not on others. Dim objLocator, objService, obj, BuildNumber Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objService = objLocator.ConnectServer( , "root\cimv2") <----- the script is failing here!!! objService.Security_.ImpersonationLevel = 4 Set obj = objService.Get("Win32_OperatingSystem=@") BuildNumber = obj.BuildNumber If obj.BuildNumber >= 6000 Then If InStr(obj.OSArchitecture,"64") Then OS = True End If End If If OS Then 'IsVista64 = True MsgBox "You are running 64-bit" Else 'IsVista64 = False MsgBox "You are running 32-bit" End If
From: Mayayana on 21 Apr 2010 09:16 If it works normally you might want to try asking in microsoft.public.platformsdk.msi You're in a slightly awkward situation. You have VBS, but it's really a WMI script, used in an MSI. There's a separate group for all of those. :) For WMI you can try microsoft.public.win32.programmer.wmi But that group doesn't see much activity, and it has a different version of the same problem: Often the people posting are using C++. The MSI group, by contrast, has a number of devoted experts who are there daily. |I have an issue that I have been struggeling with for nealy a week now with | out any success. | | The script is simple and is shown below. | When the scrip is executed from a cmd prompt there is no issue. When the | scrip is executed from within the Costum Action during installation the | scrip fails on some PC's and not on others. | | Dim objLocator, objService, obj, BuildNumber | | Set objLocator = CreateObject("WbemScripting.SWbemLocator") | Set objService = objLocator.ConnectServer( , "root\cimv2") <----- the | script is failing here!!! | objService.Security_.ImpersonationLevel = 4 | Set obj = objService.Get("Win32_OperatingSystem=@") | | BuildNumber = obj.BuildNumber | | If obj.BuildNumber >= 6000 Then | If InStr(obj.OSArchitecture,"64") Then | OS = True | End If | End If | | If OS Then | 'IsVista64 = True | MsgBox "You are running 64-bit" | Else | 'IsVista64 = False | MsgBox "You are running 32-bit" | End If |
From: LikeToCode on 21 Apr 2010 09:19 You need to tell the objService what to connect to the local machine is not assumed you have to identify it. The following script worked for me. Const strComputer = "." Dim objLocator, objService, obj, BuildNumber Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objService = objLocator.ConnectServer( strComputer, "root\cimv2") objService.Security_.ImpersonationLevel = 4 Set obj = objService.Get("Win32_OperatingSystem") BuildNumber = obj.BuildNumber If obj.BuildNumber >= 6000 Then If InStr(obj.OSArchitecture,"64") Then OS = True End If End If If OS Then 'IsVista64 = True MsgBox "You are running 64-bit" Else 'IsVista64 = False MsgBox "You are running 32-bit" End If
From: Richard Mueller [MVP] on 21 Apr 2010 11:00 "MAN" <mads.andersen(a)dantecdynamics.com> wrote in message news:%23r5ztqT4KHA.5212(a)TK2MSFTNGP04.phx.gbl... >I have an issue that I have been struggeling with for nealy a week now with >out any success. > > The script is simple and is shown below. > When the scrip is executed from a cmd prompt there is no issue. When the > scrip is executed from within the Costum Action during installation the > scrip fails on some PC's and not on others. > > Dim objLocator, objService, obj, BuildNumber > > Set objLocator = CreateObject("WbemScripting.SWbemLocator") > Set objService = objLocator.ConnectServer( , "root\cimv2") <----- the > script is failing here!!! > objService.Security_.ImpersonationLevel = 4 > Set obj = objService.Get("Win32_OperatingSystem=@") > > BuildNumber = obj.BuildNumber > > If obj.BuildNumber >= 6000 Then > If InStr(obj.OSArchitecture,"64") Then > OS = True > End If > End If > > If OS Then > 'IsVista64 = True > MsgBox "You are running 64-bit" > Else > 'IsVista64 = False > MsgBox "You are running 32-bit" > End If > I have used VBScript programs that use WMI as custom actions in InstallShield installation programs. However, I don't use SWbemLocator. Will code similar to below work: ========= Option Explicit Dim strComputer, objWMIService, colItems, objItem, bln64 Dim objNetwork Set objNetwork = CreateObjet("Wscript.Network") strComputer = objNetwork.ComputerName Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("SELECT * FROM Win32_OperatingSystem") bln64 = False For Each objItem In colItems If (objItem.BuildNumber >= 6000) Then If (InStr(objItem.OSArchitecture, "64") > 0) Then bln64 = True End If End If Next If (bln64 = True) Then Call MsgBox("Running 64-bit") Else Call MsgBox("Running 32-bit") End If ========= Perhaps the SWbemLocator code will work if you specify the computer name. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net --
From: MAN on 22 Apr 2010 03:04
Well, I have tried different approces with out any luck. I have tried an empty strin"", I have tried ".", I have even tried to specify the pc so that the msi was only valid the this perticular pc. Nothing works. I alway get the same error. It is as if the process that run the msi does not have the needed rights to connect to WMI...? "LikeToCode" <LikeToCode(a)discussions.microsoft.com> wrote in message news:4FEDD94E-16A5-4DF3-ACF7-AD2266244336(a)microsoft.com... > You need to tell the objService what to connect to the local machine is > not > assumed you have to identify it. The following script worked for me. > > Const strComputer = "." > Dim objLocator, objService, obj, BuildNumber > > Set objLocator = CreateObject("WbemScripting.SWbemLocator") > Set objService = objLocator.ConnectServer( strComputer, "root\cimv2") > objService.Security_.ImpersonationLevel = 4 > Set obj = objService.Get("Win32_OperatingSystem") > > BuildNumber = obj.BuildNumber > > If obj.BuildNumber >= 6000 Then > If InStr(obj.OSArchitecture,"64") Then > OS = True > End If > End If > > If OS Then > 'IsVista64 = True > MsgBox "You are running 64-bit" > Else > 'IsVista64 = False > MsgBox "You are running 32-bit" > End If > > |