njshaw2
Posts: 26
Joined: Fri Apr 19, 2013 10:36 am

Get error code returned by an EXE custom action

I've got a custom action running an 'attached file' which is an EXE file. That file returns 0 for ok, or some non-zero value for an error. This is picked up fine by the installer (it fails on non-zero return), but I want to be able to set a property to that return value so I don't have to abort the install, rather tell the user they've entered some invalid information and leave them on the current install dialog to amend their settings.

How can I get that return value into an installer property?

(The reason for running this EXE is to test the SQL configuration settings a user has put in. I can't use the built-in ODBC test as (a) it returns ODBC errors which will be meaningless to our users, and (b) I would have to write my own DLL to parse the MySQL registry keys to find which MySQL ODBC driver is installed so the built-in ODBC test can be called with the appropriate driver name. Neither of these are viable for our solution).

Thanks.
Eusebiu
Posts: 4959
Joined: Wed Nov 14, 2012 2:04 pm

Re: Get error code returned by an EXE custom action

Hi,

The installer cannot communicate through properties with an EXE file, only with DLL files or VBS files. So, in order to achieve what you want you can create a DLL custom action which calls your EXE file and store its return code in a property.

Then you can create a "Launch attached file" custom action without sequence that calls your DLL file and uncheck the "Fail installation if custom action returns an error" option. In the Dialogs page, use this custom action as a published event on the [Next] button of the dialog that contains the form that the user has to complete. Finally, edit the "Display a specific dialog" predefined event's condition (i.e. MY_PROP = 0).

Let us know if this helped, otherwise give us more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
njshaw2
Posts: 26
Joined: Fri Apr 19, 2013 10:36 am

Re: Get error code returned by an EXE custom action

Hi Eusebiu,

How do I set up a DLL custom action to run an EXE file that is attached to my installation but isn't an installed file? In other words, how do I get the installer to unpackage the 'attached' EXE for my DLL to run? Or will I have to include the DLL as an "installed" file and just delete it at the end?

Nick.
Eusebiu
Posts: 4959
Joined: Wed Nov 14, 2012 2:04 pm

Re: Get error code returned by an EXE custom action

Hi Nick,

Sorry, I forgot to mention that you can add your EXE file as a "Temporary File" in the Files and Folders page. In this case it will be automatically removed at the end of the "Install Execution Stage" action group.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
njshaw2
Posts: 26
Joined: Fri Apr 19, 2013 10:36 am

Re: Get error code returned by an EXE custom action

Thanks. When will it be copied to the PC if it's set as a Temporary File? I need to run my custom action within a custom dialog that is shown before the files are transferred, as the SQL settings have to be validated before file copying begins (well, specifically, before registry settings are set)...
njshaw2
Posts: 26
Joined: Fri Apr 19, 2013 10:36 am

Re: Get error code returned by an EXE custom action

Don't worry, tried it anyway and it copies that file before my dialog appears, so it's working nicely - many thanks!
Eusebiu
Posts: 4959
Joined: Wed Nov 14, 2012 2:04 pm

Re: Get error code returned by an EXE custom action

You're welcome. I'm glad you got this working.

By the way, the temporary file is copied on the PC just before the "Welcome" dialog appears, before "User Selection" action group.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”