sjwells
Posts: 6
Joined: Thu Jun 23, 2005 12:04 pm

Change the arguments of shortcut based on product selection

I have a installation with 1 main feature and 3 sub features.

The three sub features when installed should each add a different argument to the command line of the main executable shortcut contained in the main feature.

For Example:

For Just the 1st feature installed the aguments for the main executable shortcut would be

-orders

For Just the 2nd & 3rd features the aguments for the main executable shortcut would be

-scanner -pricecards

For all 3 sub features the aguments for the main executable shortcut would be

-orders -scanner -pricecards


I need to be able to store which sub features are selected somewhere and use that information in the arguments section of the shortcut.
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

The command line for the shortcut must be specified by the values of 3 properties, whose values will be modified through custom actions. Those custom actions check if a feature has been installed or not.

Here is what you should do:

- create 3 properties in the "Install Parameters" page, say "Arg1", "Arg2", "Arg3".

- create the shortcut file. In it's properties page, in the "Arguments" field use the <Edit> button to select your properties. Separate them
with spaces. Result: "[arg1] [arg2] [arg3]" - without the quotes.

- in the "Custom action" page select from the context-menu the "Show Standard Action"->"Before File Installation"->"InstallInitialize".

- for each property create two custom actions:

> the first: a "Script Inline" custom action to set the value of one property to the null string. Example:
Session.property("Arg1") = ""

> the second: a "Property Set With Formatted", to set the proper value if the corresponding feature is being installed.
In the "Property Name" field enter the name of the property. Example: Arg1
In the "Formatted Text" field enter your value:
Example: -orders.
In the "Expression" field enter the condition that checks if a feature is being installed:
(&Feature=3) AND (!Feature=2)

Advanced Installer names the feature as it follows:
- The first feature is named "MainFeature".
- The second feature is named "Feature".
- The third feature is named "Feature_1"
- The fourth feature is named "Feature_2" and so on.

So, for the second property the condition will be: (&Feature_1=3) AND (!Feature_1=2), and so on.

You can find more info on Conditional Statement Syntax on:
http://msdn.microsoft.com/library/defau ... syntax.asp

All the best,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
sjwells
Posts: 6
Joined: Thu Jun 23, 2005 12:04 pm

that seems to work ok thanks. However it doesn't allow for the command line properties to be removed if the user selects the modify button of the installation
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

That is true because once the shortcut has been created it will no longer have anything to do with a Modify operation on the package.

The only way to achieve this would be through custom actions but this is very fragile and stretches the limits of Windows Installer technology.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Mike wrote:Advanced Installer names the feature as it follows:
- The first feature is named "MainFeature".
- The second feature is named "Feature".
- The third feature is named "Feature_1"
- The fourth feature is named "Feature_2" and so on.

So, for the second property the condition will be: (&Feature_1=3) AND (!Feature_1=2), and so on.
I've just been following this thread to conditionally call a custom action and send "true" or "false" to an external batch file, depending on whether a feature is being installed.

This works but...

I've already renamed my features to be more meaningful (and there is no one feature that could be called a 'MainFeature'). Can AI be made to use the feature names that I have chosen?

The big problem comes because if (in the Organization screen) I click on my feature called 'ClientFeature', no where does it say what its internal name is (MainFeature, Feature, Feature_1, etc). Since I have many features and I have moved them around, the numbering is difficult. The only way I've found to get these names is to open up the .aip file in notepad. :(

One other thing - seeing an expression like

Code: Select all

(NOT Installed) AND ((&Feature_2=3) AND (!Feature_2=2)) OR ((&Feature_5=3) AND (!Feature_5=2))
is not very readable! :)

Thanks
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi Phil,

You are right, for the moment, working with these names is rather difficult.

We are currently working on a new feature, that will allow simplified editing for the conditions. It will also allow the user to specify a feature more easily.

This feature will probably be included in the next release of Advanced Installer.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
Phil
Posts: 22
Joined: Sat Aug 27, 2005 3:47 am

Mike wrote:This feature will probably be included in the next release of Advanced Installer.
Sounds great, I look forward to it

Thanks

Return to “Common Problems”