how to catch return from cpp file - Advanced Installer Community
vigyanlabsmys
Posts: 73
Joined: Sat May 17, 2014 12:37 pm

how to catch return from cpp file

Hi,

I have to write an cpp file based on that i.e, if cpp file returns failure, I want to abort the installation. Can you please give a simple example how to do this?

I have tried, created and exe from visual studio that exe file will return failure and I added that exe file in AD custom action and I have checked the "Fail installion if custom action returns an error" but I have got an popup, I have attached the image PFA.
Attachments
error.png
error.png (6.91 KiB) Viewed 4911 times
Best Regards,
Dan
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: how to catch return from cpp file

Hello,
I have to write an cpp file based on that i.e, if cpp file returns failure, I want to abort the installation. Can you please give a simple example how to do this?
Custom actions are actions entirely defined by the user. They can be executable files, dynamic linked libraries, Visual Basic scripts or JavaScript files.

In order to create integrate and debug custom actions, please take a look on our Options to integrate and debug custom actions article with related information for hints and guidance.
I have tried, created and exe from visual studio that exe file will return failure and I added that exe file in AD custom action and I have checked the "Fail installion if custom action returns an error" but I have got an popup, I have attached the image PFA.
Please take a look on the Logging of Action Return Values article for more details.

Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vigyanlabsmys
Posts: 73
Joined: Sat May 17, 2014 12:37 pm

Re: how to catch return from cpp file

Hi,

Thanks for reply, See I don't want to write in C#, I just want to know how to return success or failure based on that I want to abort or continue installation, How to do this?? . I have tried return 1603 in c++ code but that doesnt work.
Best Regards,
Dan
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: how to catch return from cpp file

Hello,

If you want to return error, you can return 1603 value in your custom action and the installer will fail.
I've tested this and it worked as expected. Just make sure your custom action is working property.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vigyanlabsmys
Posts: 73
Joined: Sat May 17, 2014 12:37 pm

Re: how to catch return from cpp file

Hi,

Can you send us a simple example?
Best Regards,
Dan
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: how to catch return from cpp file

Hello,

You can go in “Custom Actions” page and add the predefined Launch attached file custom action with sequence.

In the custom action properties make sure that the "Wait for custom action to finish before proceeding" option and "Fail installation if custom action returns an error" option are enabled.

Here is the cod example writen in C++.

Code: Select all

#include<stdio.h>

int main(){
    int nr = 0;
    printf("Enter the return value for your custom action:"); //0 For success, anything else for error.
    scanf("%d",&nr);

    return nr;
}
I attached a .zip archive that contains a sample project which implements your scenario.

Best regards,
Dan
Attachments
SampleProject.zip
(134.78 KiB) Downloaded 329 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”