I am trying to create a shortcut which will only be created when the user checks a checkbox.
i have tried to create a property
<Property Id ="INSTALLDESKTOPSHORTCUT" Secure="yes" />
then i created a checkbox which will change the value of this property.
<Control Id="InstallShortcutCheckbox" Type="CheckBox"
X="20" Y="140" Width="200" Height="17"
Property="INSTALLDESKTOPSHORTCUT" CheckBoxValue="1"
Text="Do you want to create a start menu shortcut?" />
then i added the shortcut tag
<Component Id="DesktopShortcut" Condition="INSTALLDESKTOPSHORTCUT">
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\Secops Solutions, Inc\Agent\Install" >
<RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes"/>
</RegistryKey>
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
Name="Life Balance" WorkingDirectory="INSTALLFOLDER"
Icon="icon" Target="DesktopFile"/>
</Component>
and i also tried to use advertise shortcut where i used two components and they both had different conditions like if
Condition = "INSTALLDESKTOPSHORTCUT"
and the other one
Condition = "NOT INSTALLDESKTOPSHORTCUT"
but that did not work either. so i have been trying to fix this and i see the shortcut in the orca editior but it doesn't still doesn't create the shortcut.
i fixed the problem.
<Component Id="DesktopShortcut" Condition="INSTALLDESKTOPSHORTCUT">
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\Secops Solutions, Inc\Agent\Install" >
<RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes"/>
</RegistryKey>
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
Name="Life Balance" WorkingDirectory="INSTALLFOLDER"
Icon="icon" Target="DesktopFile"/>
</Component>
in this code i had to change the target as following
<Component Id="DesktopShortcut" Condition="INSTALLDESKTOPSHORTCUT">
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\Secops Solutions, Inc\Agent\Install" >
<RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes"/>
</RegistryKey>
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
Name="Life Balance" WorkingDirectory="INSTALLFOLDER"
Icon="icon" Target="[#DesktopFile]"/>
</Component>
in this just change the Target to
Target=[#DesktopFile]
which is the id of the file.