Use of condition in setup

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I need the following when setup for my WinFrom app is run;

Setup gives two options A & B to the user during setup. Then depending on
the option selected by user, setup creates the app shortcut as below;

Option A
Shortcut is called A with icon 1

Option B
Shortcut is called B with icon 2 and a parameter abc passed to the app

Is it possible to achieve this via setup in VS? If so, would appreciate some
easy instructions on how to do this as there does not seem much
documentation on this.

Many Thanks

Regards
 
Basically you add both to your setup. That means adding the exe twice,
creating a shortcuts for each with the required properties (see Properties
window on each) and then using the condition on your UI to choose one or the
other. You can't separate the shortcut from its target exe in VS setup
projects because they are in the same internal component.
 
Hi Wilson

Thanks for this. How do I tie my setup ui user selection with choosing to
install one or the other exe ie what sort of coding or setting within setup
will tie the user selection which what exe setup is going to install?

Thanks again.

Regards
 
Hi Wilson

Thanks for this. How do I tie my setup ui user selection with choosing to
install one or the other exe ie what sort of coding or setting within setup
will tie the user selection which what exe setup is going to install?

I don't have the full version at home, but basically you add a custom
dialog as shown here,
http://msdn.microsoft.com/en-us/library/taa17f7s.aspx. The retrieval of
the values then can be used to set the condition property of the
shortcut install. I forget the property name, but it is something like
"install condition".

Another option is to create a custom action, which is basically a dll
you write yourself that sets up the icon. This dll can launch it's own
dialog to ask the user what they want.
 
Hi
The retrieval of the values then can be used to set the condition property
of the shortcut install. "

This is the part I am stuck at. What code/settings do I need to accomplish
this?

Many Thanks

Regards
 
John said:
Hi


This is the part I am stuck at. What code/settings do I need to accomplish
this?

Many Thanks

Regards

Well, what I thought you would do is to set the condition on the shortcut in
the File System View, but the shortcuts on the desktop don't seem to have a
condition property. The User's Desktop has the condition property.

If you added a two radio button gui to your setup project, the properties
for the dialog let you set the properties for the options. You can set a
value for Button1Value and Button2Value, which default to 1 and 2. The
ButtonProperty property was how I thought you set the condition to the
shortcut, by setting the "Condition" property to something like
"[INSTALLSC]=1". You could do this on the entire "User's Desktop" folder,
but this sounds like it wont work for you.

I don't recall the steps of creating a desktop icon in a custom action, but,
that question has been asked here before. What you would do is create a
custom action dll. Instead of a condtion though, you would pass the actuall
property ([INSTALLSC]) to the dll. The dll then looks if they chose a value
of button 1 or button 2. To pass the value to the dll, you would use this in
the CustomActionData property: /Option="[INSTALLSC]", and in the custom
action you retrieve the value with: Me.Context.Parameters("INSTALLSC").
(BTW, I usually use C#, so I use this.Context.Parameters["INSTALLSC"], but I
think I translated correctly.)

I hope this helps get you closer.

Mike
 
The underlying issue is that you cannot have a condition on a shortcut,
despite the fact that it appears that way in Visual Studio. It's bound to
its target file. That's why the op needs to:

1. Add the exe; create shortcut in option A, name it A. Drag to the required
location. Property window for the shortcut in the IDE, set the Icon
property.
2. Add the exe again in a different folder; create the shortcut B, call it
B, Property window on the shortcut has Icon and Arguments to set.
3. Add that radiobutton dialog.
4. If the property is BUTTON2 use the conditionBUTTON2=1 on one exe and
BUTTON2=2 on the other.

Visual Studio setups aren't fully featured, that's why some hoops need
jumping through here. It's not Wise, WiX, or InstallShield. The alternative
is to write code in a custom action to create shortcuts depending on the
button property value, and remember to have a corresponding uninstall custom
action too.

--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


Family Tree Mike said:
John said:
Hi


This is the part I am stuck at. What code/settings do I need to
accomplish
this?

Many Thanks

Regards

Well, what I thought you would do is to set the condition on the shortcut
in
the File System View, but the shortcuts on the desktop don't seem to have
a
condition property. The User's Desktop has the condition property.

If you added a two radio button gui to your setup project, the properties
for the dialog let you set the properties for the options. You can set a
value for Button1Value and Button2Value, which default to 1 and 2. The
ButtonProperty property was how I thought you set the condition to the
shortcut, by setting the "Condition" property to something like
"[INSTALLSC]=1". You could do this on the entire "User's Desktop" folder,
but this sounds like it wont work for you.

I don't recall the steps of creating a desktop icon in a custom action,
but,
that question has been asked here before. What you would do is create a
custom action dll. Instead of a condtion though, you would pass the
actuall
property ([INSTALLSC]) to the dll. The dll then looks if they chose a
value
of button 1 or button 2. To pass the value to the dll, you would use this
in
the CustomActionData property: /Option="[INSTALLSC]", and in the custom
action you retrieve the value with: Me.Context.Parameters("INSTALLSC").
(BTW, I usually use C#, so I use this.Context.Parameters["INSTALLSC"], but
I
think I translated correctly.)

I hope this helps get you closer.

Mike
 
Back
Top