Windows Vista Forums

using VBscript in Custom actions during installation (MSI)
  1. #1


    MAN Guest

    using VBscript in Custom actions during installation (MSI)

    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


      My System SpecsSystem Spec

  2. #2


    Mayayana Guest

    Re: using VBscript in Custom actions during installation (MSI)

    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
    |



      My System SpecsSystem Spec

  3. #3


    LikeToCode Guest

    RE: using VBscript in Custom actions during installation (MSI)

    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



      My System SpecsSystem Spec

  4. #4


    Richard Mueller [MVP] Guest

    Re: using VBscript in Custom actions during installation (MSI)


    "MAN" <mads.andersen@newsgroup> wrote in message
    news:%23r5ztqT4KHA.5212@newsgroup

    >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
    --



      My System SpecsSystem Spec

  5. #5


    MAN Guest

    Re: using VBscript in Custom actions during installation (MSI)

    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@newsgroup> wrote in message
    news:4FEDD94E-16A5-4DF3-ACF7-AD2266244336@newsgroup

    > 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
    >
    >

      My System SpecsSystem Spec

using VBscript in Custom actions during installation (MSI) problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
are VBscript on Windows server 2003 and VBscript on WS2008 compatible? Francois Lafont VB Script 9 26 Apr 2010
background image in first phase of a custom installation of Vista SP164-bit Mazzaroc Vista installation & setup 0 21 May 2009
Windows Live Messenger, Custom installation destination? Falcubar Live Messenger 2 17 Aug 2008
Custom Installation Disc Matthew Schwarz Vista installation & setup 6 12 Mar 2008
Will Windows Vista have custom installation? Phillip Pi Vista installation & setup 3 03 Jun 2006