/build/static/layout/Breadcrumb_cap_w.png

Calling a VBScript in a msi Custom Action

I have an app that requires Outlook to be closed before it will install. If Outlook is open when the install is ran the installation will fail and leave keys behind in HKCR which prevents the install from running afterwards even when Outlook is closed. Right now our deployment method has been to instruct users to close before the install the app but inevitable some people forget and then need the Reg fix ran on their machine to clean up the left-behind keys. As an alternative I have been attempting to create a Custom Action in the MSI using AdminStudio that uses a VBScript to close Outlook.

So far I have created a VBScript CA that stores the .vbs file in a binary table within the msi. Here is a copy of the script..

Set objOutlook = CreateObject("Outlook.Application")
objOutlook.Quit

WScript.Sleep 30000

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Outlook.exe'")
For Each objProcess in colProcessList
   objProcess.Terminate()
Next

The script works fine when ran on its own but my install continues to hang on this CA when I run the msi with Outlook open. In-Script Execution is set to Immediate Execution and as of now there are now Property conditions set until I know it works at its most basic level. It is set to run between InstallInitialize and InstallFinalize.

The error mesage that pops up during install states "There is a problem with this Windows Installer package. A script required for this install to complete could not be run." When i look at the logs, sure enough it stops at my new CA.

Any ideas as to what I am doing wrong?


0 Comments   [ + ] Show comments

Answers (2)

Posted by: kiptek 10 years ago
Second Degree Green Belt
0

Set WSHShell = CreateObject("WScript.Shell")


Comments:
  • Would you mind adding that to my script? - quattro004 10 years ago
Posted by: anonymous_9363 10 years ago
Red Belt
0

If the script is being run as an embedded script, it's using the VBScript interpreter (let's call it) in Windows Installer's engine and not Windows Scripting Host. Therefore, you cannot use 'WScript' methods, such as 'WScript.Sleep'. Note that this only applies to methods and properties: you can still access WScript objects like 'WScript.Shell', as shown above. It's best summarised this way:

   Set objWSHShell = WScript.CreateObject("WScript.Shell")    '// Will fail
   Set objWSHShell = CreateObject("WScript.Shell")    '// Will work

If you have to have the script sleep - and I can't imagine why you would in this case - there are innumerable examples around, most of which peform a loop PINGing the localhost address.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ