cancel
Showing results for 
Search instead for 
Did you mean: 
HenrikA
Pilgrim

Checking for running process with VB Script in Custom action fails?

Trying to check if Outlook is running with the following VB script in a Custom Action:


[/HR]
On Error Resume Next
Dim Outlook: Set Outlook = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
' Outlook is running
MsgBox "Outlook is currently running. Please close it to proceed installation.", 16, "Setup"
Else
' Outlook is not running
Err.Clear
End If
On Error Goto 0

[/HR]

Every time I try to run the build installation package it fails with this error:

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 ProcessCheckerScript script error -2146827256, Microsoft VBScript compilation error: Invalid character Line 1, Column 1, On Error Resume Next

Anyone who can guide me in the right direction so that I can check if the process is running before installing and then ask user to close the process before user can continue the installation?
Labels (1)
0 Kudos
2 Replies
Flexera Jenifer
Flexera

Re: Checking for running process with VB Script in Custom action fails?

HenrikA wrote:
Trying to check if Outlook is running with the following VB script in a Custom Action:


[/HR]
On Error Resume Next
Dim Outlook: Set Outlook = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
' Outlook is running
MsgBox "Outlook is currently running. Please close it to proceed installation.", 16, "Setup"
Else
' Outlook is not running
Err.Clear
End If
On Error Goto 0

[/HR]

Every time I try to run the build installation package it fails with this error:

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 ProcessCheckerScript script error -2146827256, Microsoft VBScript compilation error: Invalid character Line 1, Column 1, On Error Resume Next

Anyone who can guide me in the right direction so that I can check if the process is running before installing and then ask user to close the process before user can continue the installation?


Hi,

It looks like vb script compilation issue on your machine,the same code i could compile without any issues.Did you give a try with some other vbscript-compiler to check is that related to vb-script binary issue?
I had given a try with the same code you had given,but sequenced after InstallFinalize in ExecuteSequence.I could able to get messagebox saying "Not running" in machine where there is no outlook running.Can you tell me about your sequencing?

Thanks,
Jenifer
0 Kudos
HenrikA
Pilgrim

Re: Checking for running process with VB Script in Custom action fails?

Jenifer wrote:
Hi,

It looks like vb script compilation issue on your machine,the same code i could compile without any issues.Did you give a try with some other vbscript-compiler to check is that related to vb-script binary issue?
I had given a try with the same code you had given,but sequenced after InstallFinalize in ExecuteSequence.I could able to get messagebox saying "Not running" in machine where there is no outlook running.Can you tell me about your sequencing?

Thanks,
Jenifer


Hi Jenifer

I did test placing the script after InstallFinalize and then it works, this is an okay solution Smiley Happy

But now i found a new issue, GetObject cant see if Outlook is running because the installer runs in admin context and outlook run is user context Smiley Sad

I triede to change the vbscript to this:

Const strComputer = "."
Const strProcess = "outlook.exe"

Dim wmiQuery : wmiQuery = "Select * From Win32_Process Where Name='" _
& strProcess & "'"
Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer _
& "\root\cimv2")
Dim colItems : Set colItems = objWMIService.ExecQuery(wmiQuery)

Dim intProcCount : intProcCount = colItems.Count
Do While intProcCount > 0
MsgBox "Outlook is currently running. Please close it to proceed installation.", 16, "Setup"
Set colItems = objWMIService.ExecQuery(wmiQuery)
intProcCount = colItems.Count
WScript.Sleep 1000
Loop

This new vb script work and will tell Outlook is running but then it fails when I click the OK button in the msgbox with this error:

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 CheckIfOutlookIsOpen script error -2146827864, Microsoft VBScript runtime error: Object required: 'WScript' Line 15, Column 9,

If I run the exact same code in VbsEdit then it runs without any issue on my computer
0 Kudos