cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
savy17
Level 5

IDABORT is not aborting installation in all scenarios when called in VB Script

I am creating an Basic MSI installer.

I need to make sure that the application that I am installing is not currently running. In order to do so, I created a VBScript which checks whether the application is running or not. If the application is running, it displays a message box asking the user to close the application. The messagebox has two buttons Retry and Cancel. When Retry is clicked, I am calling same function recursively to verify that the user has closed the application. However if the user clicks cancel, I want to abort the installation.

If my Hello World.exe is running, it shows the message box with two buttons. If I close the application now and then click Retry again, it proceed with the installation.

However, Cancel seems not working correctly. If the message box is displayed very first time and user clicks 'Cancel', it aborts the installation. However if user clicks Retry (without closing the application) one or more time, and then afterward click Cancel, it doesn't abort the application.

Any suggestion what I am doing wrong.
I would appreciate any help. Thanks.

Here is the vbscript function CheckRunningProcess that I am calling from the custom action in my installer.

Function CheckRunningProcess()
Const IDABORT = 3
Dim Wmi, Wql, Processes
Set Wmi = GetObject("winmgmts:")
Wql = "select * from Win32_Process where name ='Hello World.exe'"
Set Processes = wmi.execquery(wql)
If Processes.Count > 0 Then
result = MsgBox ("Hello World is running. Please Close Hello World",vbRetryCancel+vbDefaultButton2,"Close Running Application")
If result = 4 Then
FindProcess()
ElseIf result = 2 Then
FindProcess = IDABORT
Else
FindProcess = IDABORT
End If
End If
End Function
Labels (1)
0 Kudos
(1) Reply
savy17
Level 5

Can anybody suggest why its not working...

savy17 wrote:
I am creating an Basic MSI installer.

I need to make sure that the application that I am installing is not currently running. In order to do so, I created a VBScript which checks whether the application is running or not. If the application is running, it displays a message box asking the user to close the application. The messagebox has two buttons Retry and Cancel. When Retry is clicked, I am calling same function recursively to verify that the user has closed the application. However if the user clicks cancel, I want to abort the installation.

If my Hello World.exe is running, it shows the message box with two buttons. If I close the application now and then click Retry again, it proceed with the installation.

However, Cancel seems not working correctly. If the message box is displayed very first time and user clicks 'Cancel', it aborts the installation. However if user clicks Retry (without closing the application) one or more time, and then afterward click Cancel, it doesn't abort the application.

Any suggestion what I am doing wrong.
I would appreciate any help. Thanks.

Here is the vbscript function CheckRunningProcess that I am calling from the custom action in my installer.

Function CheckRunningProcess()
Const IDABORT = 3
Dim Wmi, Wql, Processes
Set Wmi = GetObject("winmgmts:")
Wql = "select * from Win32_Process where name ='Hello World.exe'"
Set Processes = wmi.execquery(wql)
If Processes.Count > 0 Then
result = MsgBox ("Hello World is running. Please Close Hello World",vbRetryCancel+vbDefaultButton2,"Close Running Application")
If result = 4 Then
FindProcess()
ElseIf result = 2 Then
FindProcess = IDABORT
Else
FindProcess = IDABORT
End If
End If
End Function
0 Kudos