mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Launch custom file after install

I am trying to launch a file after install and I am getting hung up on the control events.
https://www.advancedinstaller.com/user- ... ation.html

Modify the "Execute custom action" control event's condition to use the property of the checkbox:

Code: Select all

Execute custom action   myapp.exe   AI_INSTALL AND CHECK
When I place that line into the condition window I get an error. Perhaps I am taking that line to literally?

Image
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch custom file after install

Hello,
Perhaps I am taking that line to literally?
That is exactly what happens :)
Execute custom action myapp.exe AI_INSTALL AND CHECK
The above strings refer to:

Execute custom action --> the event

myapp.exe --> the application to be launched

AI_INSTALL AND CHECK --> the condition of the event

The application to be launched will be configured in the "Custom Actions" page, when adding the "Launch File" custom action, e.g.:
CA.png
CA.png (110.13 KiB) Viewed 6362 times

The event can be configured on your dialog, e.g.:
Event.png
Event.png (191.3 KiB) Viewed 6362 times

Lastly, the condition can be configured either directly in the "Condition" field or by pressing the "..." button, e.g.:
Condition.png
Condition.png (198.54 KiB) Viewed 6362 times

Where "1" is the default condition and it means "AI_INSTALL". From the above screenshot, you can actually remove "1" and leave only "CHECK" as a condition. After doing so, the event will look like this:
Condition2.png
Condition2.png (15.43 KiB) Viewed 6362 times


Hope the explanations helps and things are clearer now.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Launch custom file after install

Thank you. I seemed to have it all right but that last part. I tried to launch the file after installation and it never executed. The file I am trying to execute is already installed on the machine, and is not a part of my package.

Image
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch custom file after install

Hello,

You are always welcome.
I tried to launch the file after installation and it never executed.
Have you got this working in the end, or you require assistance?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Launch custom file after install

The file does not execute, so I will need further assistance.
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch custom file after install

Hello,

That most probably happens because the file is not found.

Please keep in mind that, in order to launch a file, you will need to provide the full path to it.

In my screenshot, I have used the "notepad.exe" app, which is part of the Windows Apps, which is part of the %PATH% environment variable. Whatever is added in the %PATH% environment variable, the Windows will know to launch it without you needing to give the full path to it.
PATH.png
PATH.png (91.24 KiB) Viewed 6347 times


For instance, if you open a run command window (press WIN+R) and type "notepad.exe" (without quotes), the notepad will be launched - you do not have to give the full path to it.

However, if you type another application that is not part of the %PATH% environment variable, the Windows OS will not know its location.

With that being said, please provide the full path to your executable and let me know if that helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Launch custom file after install

In my screenshot I have the working directory set to H:\ which is where the program is.
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch custom file after install

Hello,

You are right, I did not notice that you have set the working directory. I apologize for that.

I think you have not scheduled the custom action right.

Can you please try to trigger it from the "Finish" button and let me know if that helps? To do so, simply click on the "Finish" button and then add, under "Published Events", an "Execute custom action" event which has as argument the "Launch File" custom action.
LF.png
LF.png (202.93 KiB) Viewed 6341 times

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Launch custom file after install

I attached the event to the checkbox. Is this not right?

Image
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch custom file after install

Hello,
Is this not right?
No, it is not.

You should attach the custom action to a push-button type control. For instance, you could use the "Finish" button as explained in my last thread.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Launch custom file after install

How does it get tied to the check box though?
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch custom file after install

Hello,

This gets tied to the checkbox through the "Condition" field of the event.

Basically, we use the checkbox property to decide whether the event is executed or not.

For instance, if the checkbox is checked, its property value will be:

Code: Select all

CHECK = "CheckBox"
Otherwise, the property value will be:

Code: Select all

CHECK = ""
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mccorkled
Posts: 23
Joined: Wed Feb 05, 2020 5:32 am

Re: Launch custom file after install

I believe this is almost working as it should. The program opens but the installer hangs and I get this error after a few minutes...

Image
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: Launch custom file after install

Hello,

This might be happening if your program is returning, upon exit, an error != 0.

Windows Installer interprets any error code that is different than 0 as a failure, therefore the message you are getting.

The fact that your program is launched as expected means that there is no problem with the custom action itself.

There are two things that can be done here:

1. If you are the developer of the application, you should make sure that it is returning 0.

2. You can ignore the return code of your application by going to "Custom Actions" page --> your custom action --> uncheck the "Fail installation if custom action returns an error" option from under the "Execution Options" section.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”