
WMI call fails in Custom VBScript Action
Posted 15 April 2010 - 08:32
CODE |
Error 1720.There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action XXX script error -2146827859, Microsoft VBScript runtime error: ActiveX component can't create object: 'objWMIService.ExecQuery' Line 52, Column 2, MSI (s) (90:9C) [16:04:01:289]: Product: XXX -- Error 1720.There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action XXX script error -2146827859, Microsoft VBScript runtime error: ActiveX component can't create object: 'objWMIService.ExecQuery' Line 52, Column 2, |
The script code generating the error looks like this:
CODE |
Function IsVista64() Dim objWMIService, colOSes, objOS, BuildNumber, OS OS = False BuildNumber = 0 Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Call}!\\.\root\cimv2") Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOS in colOSes BuildNumber = objOS.BuildNumber 'Vista If BuildNumber >= 6000 Then If InStr(objOS.OSArchitecture,"64") Then OS = True End If End If Next If OS Then IsVista64 = True Else IsVista64 = False End If End Function |
Looking on the web a lot of cases describe this, but mostly for Remote calls using WMI. The excact same code run if ran from the command prompt, but fails when called from the installation. It works on some computers and fails on others. Probably a case of user permissions etc. ??
Nailing down the problem further, please see the following excample:
The following code fails inside a VBScript custom action, but runs outside:
(http://msdn.microsof...a393720(v=VS.85).aspx)
CODE |
Dim objLocator, objService, objOS Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objService = objLocator.ConnectServer( , "root\cimv2") <----- call failes ? objService.Security_.ImpersonationLevel = 4 Set objOS = objService.Get("Win32_OperatingSystem=@") |
Please help!
-cpede
Posted 16 April 2010 - 10:14
When you run it in the command prompt, you probably use your own account, not LOCALSYSTEM.
To fix the issue, either do:
1. Ask the user to change the Windows Installer account - which also affects al future installs, repairs and uninstalls, don't forget to remind him to set it back.
2. Move the code to the UI sequence - but at that stage the UAC may not be in effect
3. Ask the the user for credentials to run the WMI, at the beginning of the CA switch the context to those credentials. I don't think that's possible in VBScript.
4. Ask the user for credentials to run the WMI, and pass those credentials when communicating with WMI. I quite sure that WMI is capable of doing its work in different credentials than its caller.
Posted 19 April 2010 - 13:20
VersionNT64
Msix64
Intel64
Stefan Krüger
InstallSite.org twitter facebook
Posted 01 January 2014 - 21:38
hi,
i'm also have the same problem. code work ok from vbs file, but fail if run from MSI
Code:
Posted 01 January 2014 - 22:03
VB script custom actions are run by msi itself, not Wsript.Remove the first line (CreateObject) and see if it works.
Stefan Krüger
InstallSite.org twitter facebook
Posted 01 January 2014 - 22:05
Hi, Stefan. it is product from my partner, not my code. it is ok to install in XP and some other windows 7 machines, but the problem on my laptop.