Fail Installation - Advanced Installer Community
nirs
Posts: 42
Joined: Wed Aug 13, 2014 2:46 pm

Fail Installation

Hi,
I want to fail my installation if a service is not running.
How can I do it?

I need that the failure will return an errorcode bigger than 0.

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

Re: Fail Installation

Hi,

To achieve this you can go in the "Custom Actions" and add the "Detect service" custom action then add a "Display error message" custom action and set the AI_SERVICE_STATE = "Stopped" condition for it.

If you do not want to display any message box, you can use the VBScript custom action found at this thread instead of the "Display error message" custom action.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nirs
Posts: 42
Joined: Wed Aug 13, 2014 2:46 pm

Re: Fail Installation

Hi.

I just created an empty project that only has the 'Error message' custom action.(See attached aip)
Upon executing via the UI I get the error.
Upon executing via quiet installation (See attached screenshot) the errorlevel remains 0 although the log indicate for a failure (see atacched log).

Please check it and advice.

Thanks
Attachments
1.txt
The execution log
(27.22 KiB) Downloaded 401 times
Your Application.aip
The application aip
(10.68 KiB) Downloaded 486 times
Wrong Error level
Wrong Error level
2014_09_08_11_25_48_C_Windows_system32_cmd.exe.png (6.35 KiB) Viewed 5595 times
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Fail Installation

Hello,

This may happen if you manually run, in turn, the above commands on a command prompt window. Please keep in mind that the %ERRORLEVEL% environment variable stores the exit code of the most recently ran program. So, if in between the call of your first command (msiexec /i "Your Application.msi" /quiet /log 1.txt) and the call of the second one (echo %errorlevel%) another program runs and exit a code (0), then the %ERRORLEVEL% environment variable will store the 0 exit code.

Can you please create a BAT file with the following content:

Code: Select all

msiexec /i "Your Application.msi" /quiet /log 1.txt
echo %errorlevel%
pause
and manually launch it and see if the correct exit code (of the MSI installation) is displayed?

Also, I've attached a sample (created with AI 11.0) which implements this scenario.
sample.zip
(116.34 KiB) Downloaded 438 times
If you have any question let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nirs
Posts: 42
Joined: Wed Aug 13, 2014 2:46 pm

Re: Fail Installation

Thanks Daniel.
Using the batch it worked.
I suggest to specify that issue for future customers.

Nir
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Fail Installation

You're welcome Nir. Maybe we'll update our help files with this info in a future version of AI. Thank you for your suggestion.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”