Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

WMI call fails in Custom VBScript Action


5 replies to this topic

cpede

cpede
  • Full Members
  • 2 posts

Posted 15 April 2010 - 08:32

From the log file I have extracted the following:

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


Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 16 April 2010 - 10:14

If the custom action is scheduled in the InstallExecuteSequence, the it is run by the account scheduled for the Windows Installer Service, usually LOCALSYSTEM.
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.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 19 April 2010 - 13:20

And if all you need to find out is whether this is a 64 bit system, one of the following pre-defined properties may already tell you all you need to know:
VersionNT64
Msix64
Intel64

Asaf

Asaf
  • Full Members
  • 2 posts

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:

      Set WShell = CreateObject("WScript.Shell")
      dim opened
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colProcessList = objWMIService.ExecQuery _
      ("SELECT * FROM Win32_Process WHERE Name = 'onexcui.exe'")
 
Error 1720 can't create object container ActiveX: 'objWMIService.ExecQuery


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

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.



Asaf

Asaf
  • Full Members
  • 2 posts

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.