mentalmushroom
Posts: 63
Joined: Wed Feb 08, 2012 8:08 am

Require a prerequisite application to be closed

Hello

We use an external application (player) in our software. In order to install it correctly it should not be running. Is it possible to ask a user to close it if it's running?

I have read this article and watched this tutorial, but it looks like this way can show the message only once. But what if it's still running? The message should be shown again and again until it's closed. How can it be done?
No milk today
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: Require a prerequisite application to be closed

Hello,
Is it possible to ask a user to close it if it's running?
Yes, that is possible. The article/tutorial you have linked can help you achieve exactly what you want.
But what if it's still running?
I think that you should not worry about such case, since I doubt it is possible. The custom action should successfully stop the process. Are you facing such an issue? Maybe you have incorrectly configured the custom action.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mentalmushroom
Posts: 63
Joined: Wed Feb 08, 2012 8:08 am

Re: Require a prerequisite application to be closed

I think that you should not worry about such case, since I doubt it is possible. The custom action should successfully stop the process. Are you facing such an issue? Maybe you have incorrectly configured the custom action.
So far I have not faced issues about stopping the process. However, I would like to take care of such a case when the process hung up or just busy with something preventing it from being closed.

Generally speaking, I would prefer not to close it by means of Advanced Installer, but ask a user to do that. So it is possible that they press "Ok" but do not close the program.

In case we ask a user to close it automatically, what if they answer "No"?
No milk today
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: Require a prerequisite application to be closed

Hello,

Unfortunately, I am afraid we do not have predefined support for such a task. The installation process is made up of standard and custom actions that are run in sequence. Once an action has finished executing, the next one enters in execution.

However, what you want to achieve is possible through the help of a custom action. I have created a PowerShell script for your reference which spawns a message box and based on the results, either continues by closing the message box (if the user presses "Yes") or loops through (when the user presses "No") until the user presses "Yes":

Code: Select all

Add-Type -AssemblyName PresentationFramework

$msgBoxInput = [System.Windows.MessageBox]::Show('The setup requires you to close the X application in order to continue. Do you want to automatically close the X application?', 'Title', 'YesNo')

if ($msgBoxInput -eq 'Yes'){[System.Windows.MessageBox]::Show('The application was closed')}
elseif($msgBoxInput -eq 'No'){
do{
$msgBoxInput = [System.Windows.MessageBox]::Show('The setup requires you to close the X application in order to continue. Do you want to automatically close the X application?', 'Title', 'YesNo')
if ($msgBoxInput -eq 'Yes'){[System.Windows.MessageBox]::Show('The application was closed')}
}
until ($msgBoxInput -eq 'Yes')
}
The above script can be further configured to match your needs.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mentalmushroom
Posts: 63
Joined: Wed Feb 08, 2012 8:08 am

Re: Require a prerequisite application to be closed

This script repeatedly shows the message until 'Yes' is pressed, but the desired behavior is to show this message while the process is running. Is it possible to do that?

Code: Select all

while (process_is_running("program.exe"))
{
	if (message("Do you want to automatically close the X application?") == YES)	
		terminate_process("program.exe");	
}
The second question I have is localization. How can the text from the script be translated into different languages?
No milk today
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: Require a prerequisite application to be closed

Hello,

I have created the above script just for the sake of an example.
...but the desired behavior is to show this message while the process is running. Is it possible to do that?
Yes, it is possible to do that. The script is fully configurable.
The second question I have is localization. How can the text from the script be translated into different languages?
Custom actions are actions entirely defined by the user. They can be executable files, dynamic linked libraries (C++/C#), Visual Basic scripts, JavaScript or PowerShell scripts. For more information about this, please have a look on the following articles:

- How to create fully fledged C# custom actions

- "Custom Actions List"

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”