Setting properties from inside the installer - 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!

davidnewcomb
Posts: 19
Joined: Fri Apr 09, 2010 5:04 pm

Setting properties from inside the installer

I know you can override upper case properties from the msiexec command line, but is it possible to do it from inside the installer as it runs.
Something like running a custom action that generates a list of "property = value" which gets read back in.
Should the custom action set environment variables that can be picked up later in the installation process (is this even possible?).

What I want to do is pre-populate the answers to the questions with the answers given the last time the installer was run (like in the case of control panel->app->modify).
In some cases I may want to read options from a database to help configure the installation.

Any help or guidance would be great.
Thank,
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Setting properties from inside the installer

Hello,

This is easy actually.
The answers should be stored in the per-user registry hive, HKCU.
Then they can be retrieved through a registry search and stored in properties.

Our guide explains both how to do a registry search and how to write registry.
In some cases I may want to read options from a database to help configure the installation.
This seems like custom behavior. I believe you need to write a custom action for this.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
davidnewcomb
Posts: 19
Joined: Fri Apr 09, 2010 5:04 pm

Re: Setting properties from inside the installer

I told you it would probably be a custom action in my question! But saying "you can do that in a custom action" is so generic that it is not any help.

So what do I do with the custom action? If it has to be a separate program that can only return 0, how do I get the properties updated in the installer?
Can the CA write out "property = value" pair that can be picked up or should the CA be responsible for writing to the registry then AI can read it out?

Any help, advice or documentation references would be handy.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Setting properties from inside the installer

Hello,

Executable custom actions can return 0 for success and non-zero for failure. They can not set properties.
For setting properties you will either need a DLL custom action which exports a function with the following signature:

Code: Select all

UINT __stdcall ValidateSerial_Sample(MSIHANDLE hInstall) 
or a VBScript custom action.
The C++ MSI API has the MsiSetProperty function to set properties, while in a VBScript you can set a property using:

Code: Select all

Session.Property("YOUR_PROPERTY_NAME") = <value>
Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”