by Markus
2. November 2009 21:26
Installing Shortcuts on Desktop and in Programs Menu
Step 1
Define the Directories (Folders) for the Shortcuts (We have done this already in the chapter Installing the Files…)
<!--****************************************************************************************-->
<!--Define Folders for the Setup-->
<!--****************************************************************************************-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<!--Folder for All Programm Files-->
<Directory Id="COMPANYROOTDIRECTORY" Name="$(var.ManufacturerFolderName)">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="$(var.ProductName)">
<Directory Id="APPLICATIONDATADIRECTORY" Name="DataSubDir" />
</Directory>
</Directory>
<!--Folder for Menu Items-->
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuCompanyFolder" Name="$(var.ManufacturerFolderName)">
<Directory Id="ProgramMenuAppFolder" Name="$(var.ProductName)"/>
</Directory>
</Directory>
<!--FOlder for Desktop-->
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
</Directory>
Step 2
Place the following code in the Product.wxs to create the Program Menu items.
<DirectoryRef Id="ProgramMenuAppFolder">
<Component Id="ApplicationShortcut" Guid="{A469B906-8CA9-4a85-96AF-2A00F7DF5CD6}">
<CreateFolder Directory="ProgramMenuAppFolder" />
<RemoveFolder Id="RemoveProgramMenuAppFolder"
Directory="ProgramMenuAppFolder"
On="uninstall"/>
<RemoveFolder Id="RemoveProgramMenuCompanyFolder"
Directory="ProgramMenuCompanyFolder"
On="uninstall"/>
<Shortcut Id="ApplicationStartMenuShortcut"
Name="$(var.ProductName)"
Description="The ONE and ONLY $(var.ProductName)"
Target="[APPLICATIONROOTDIRECTORY]TheTester.exe"
WorkingDirectory="APPLICATIONROOTDIRECTORY"
Icon="APP.ico" />
<Shortcut Id="UninstallProduct"
Name="Remove $(var.ProductName)"
Description="Remove $(var.ProductName) form the Computer."
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]"
Icon="Setup.ico"
/>
<!--We need the Registry Key just to give the Component a KeyPath-->
<RegistryValue Root="HKCU" Key="Software\$(var.ManufacturerFolderName)\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
Step 3
Place the following Code in the Product.wxs File to create the Desktop Icon.
<DirectoryRef Id="DesktopFolder">
<Component Id="ApplicationShortcutDesktop" Guid="{abd65e7e-3d42-4192-9839-9e7c010449de}">
<Shortcut Id="DesktopShortcut"
Name="$(var.ProductName)"
Description="starts $(var.ProductName)"
Target="[APPLICATIONROOTDIRECTORY]TheTester.exe"
WorkingDirectory="APPLICATIONROOTDIRECTORY"
Icon="APP.ico" />
<!--We need the Registry Key just to give the Component a KeyPath-->
<RegistryValue Root="HKCU" Key="Software\$(var.ManufacturerFolderName)\$(var.ProductName)" Name="installedDesktopShortcut" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<= Back to Content
46ae961c-46b1-47ca-bed3-8f013be32a64|0|.0
Tags: