Return code ignored from batch file - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

kraigh
Posts: 4
Joined: Fri Mar 28, 2008 2:08 am

Return code ignored from batch file

I'm trying to get a custom action (exe that's a batch file) to cause the installer to fail if it returns an error. The custom action is set to Synchronous exection, check return code and Deferred.

The batch file returns an error with:

exit 1
or
exit /b 1

I've tried other codes as well (e.g. 1602), but the installer seems to ignore it?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Return code ignored from batch file

Hi,

Please note that Windows Installer does not support BAT files as custom actions. Therefore, Advanced Installer allows you to launch BAT files through a custom EXE ("viewer.exe"). This EXE cannot evaluate the return code of a BAT file, therefore you cannot return a code from a BAT custom action.

In order to return a code you can use an EXE, DLL, VBScript or JScript custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bjk68
Posts: 55
Joined: Tue Dec 01, 2009 12:45 pm

Re: Return code ignored from batch file

cosmin wrote:Advanced Installer allows you to launch BAT files through a custom EXE ("viewer.exe"). This EXE cannot evaluate the return code of a BAT file, therefore you cannot return a code from a BAT custom action.
Maybe you could try to create an enhanced version of viewer.exe that CAN evaluate the return code of a BAT file? This would be very helpful.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Return code ignored from batch file

Hi,

I'm afraid that this wouldn't help. For EXE custom actions 0 means success and any other value means failure. This is the way Windows Installer works.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bjk68
Posts: 55
Joined: Tue Dec 01, 2009 12:45 pm

Re: Return code ignored from batch file

cosmin wrote:For EXE custom actions 0 means success and any other value means failure. This is the way Windows Installer works.
The current version of viewer.exe always returns 0 (success). Even if the BAT file fails with EXIT 1 or EXIT /b 1. We don't need more than success or failure, but now we always get success.

The new enhanced version of viewer.exe should interpret the exit value of the BAT script, and return success or failure to the Windows Installer. So when the BAT file fails, the viewer.exe should fail too. The failure can bubble up this way to the Windows Installer.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Return code ignored from batch file

Hi,

I added this improvement on our TODO list and it will be available in a future version of Advanced Installer. Thank you for your suggestion. Until then a solution would be to create a custom DLL which runs the BAT and then returns a custom code.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”