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

Comments

Please log in to comment

Answers

0

Set WSHShell = CreateObject("WScript.Shell")

Answered 04/10/2014 by: kiptek
Second Degree Green Belt

  • Would you mind adding that to my script?
Please log in to comment
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.

Answered 04/11/2014 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity