From: MAN on
Hi Richard,
Thank you !

I tried the script you suggested, but it failes in the error message:
Line: 4
Char: 1
Error: Type mismatch: 'CreateObject'
Code: 800A000D
Source: Microsoft VBScript runtime error

I guess that I do not have acces to "Wscript.Network".

Any how, I have tried to enter the mashine name in the script so that this
scrip would only work on the PC where it fails... and it still fails.

Any other suggestions ?

regards
Mads

"Richard Mueller [MVP]" <rlmueller-nospam(a)ameritech.nospam.net> wrote in
message news:eAdw5NW4KHA.6060(a)TK2MSFTNGP04.phx.gbl...
>
> "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
> --
>
>