Reading from file / using return value as condition - 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!

quazer
Posts: 4
Joined: Tue Jan 01, 2013 8:41 am

Reading from file / using return value as condition

Hello
I am facing a problem in reading data from file.
Basically I have to read data from a text file store in temp directory which will decide which of the two dialog screen will be shown during install.
While I was searching similar options, I didn't find anything in AI.
I was thinking of writing C# command line application to read data from file and return the exit flags. Those exit flags can be used in AI to show proper screen.

Well, here I need help to capture return value.

My process in short.
> Run custom action in first screen next button, which will return proper code.
> Code will decide which dialog box will be shown among two.

So, how to get this stuff work. :roll:
Did I am missing something simpler that AI offers me ?

Thank You
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Reading from file / using return value as condition

Hi,

Advanced Installer has a file search support, but only for XML files, so you cannot use it in this scenario. Using the C# custom action is correct, but you need to make some changes.

First of all, your custom action must always return 0, otherwise it will be interpreted as a failure by the OS. To pass value from your code to the install you will use public properties. The next article also explains how to run your custom action when a button is pushed.

Once you have that ready you can just right click on the dialog you want to display based on your condition and use the option "Show only if".

Best regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
quazer
Posts: 4
Joined: Tue Jan 01, 2013 8:41 am

Re: Reading from file / using return value as condition

Sorry Bogdan
But the things went over the roof. :shock:
Can you please provide me a simple example to work it out.
I didnt get how to store the result of custom action in public property.

I was planning to use exe file to read the file and provide appropriate condition.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Reading from file / using return value as condition

Hello,

Please keep in mind that you cannot set an installer property from an exe custom action. An installer property can be set only from Win32 DLL or VBScript custom actions. Also, if you want to set or get a property value from within a DLL you would need to use the MsiSetProperty or MsiGetProperty functions. If you need to get or set a property value from a VB Script custom action, then you can use Session.Property property.

Here's attached a sample, created using version 9.8 of Advanced Installer, which implements a similar scenario.
sample.zip
(3.38 KiB) Downloaded 224 times
If you have any questions let us know.

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

Return to “Common Problems”