I have an installer that creates a folder "_source" in the targetdir, which contains the "SAMPLE.exe" and other files. I am trying to generate a shortcut that will point to that exe but it seems to generate/copy that exe and place it in the target directory. Its able to run the executable but since other files are needed in the _source directory, it cannot continue. How do I point to the exe in _source without making a copy of that exe?
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" SourceName="Desktop"/>
<Directory Id="MergeRedirectFolder">
<Component Id="ApplicationShortcut" Guid="1D120AC7-6BAC-4F99-8611-029ED3F2EA3A">
<File Id="MyExeFile" Source="!(wix._source)\SAMPLE.exe" KeyPath="yes">
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="SAMPLE" WorkingDirectory="MergeRedirectFolder"
Icon="SAMPLE.exe"
IconIndex="0"
Advertise="yes" >
<Icon Id="SAMPLE.exe" SourceFile="!(wix._source)\icon1.ico" />
</Shortcut>
</File>
</Component>
</Directory>
If you are attempting to install under program files, i would start with something like this:
<Product ...>
...
<Feature ...>
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Icon Id="SAMPLE.ico" SourceFile="!(wix._source)\icon1.ico" />
</Product>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="MergeRedirectFolder" />
</Directory>
<Directory Id="DesktopFolder" SourceName="Desktop"/>
</Directory>
<ComponentGroup Id="ProductComponents" Directory="MergeRedirectFolder">
<Component Id="ApplicationShortcut" Guid="1D120AC7-6BAC-4F99-8611-029ED3F2EA3A">
<File Id="MyExeFile" Source="!(wix._source)\SAMPLE.exe" KeyPath="yes">
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="SAMPLE" WorkingDirectory="MergeRedirectFolder"
Icon="SAMPLE.ico"
IconIndex="0"
Advertise="yes" />
</File>
</Component>
</ComponentGroup>
Related
I have created an installer of a c# application. Now I want to add a Desktop shortcut: I have followed the WiX official documentation as well as the other suggested answers on this site but still my installer doesn't create the shortcut.
No errors occur during the compilation. My .wsx file is the following:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="Myapp">
<Component Id="Trojan2CostCalculator.exe" Guid="*">
<File Id="Myapp.exe" Source="$(var.Myapp.TargetPath)" KeyPath="yes" Checksum="yes"/>
</Component>
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="ApplicationShortcutDesktop" Guid="*">
<Shortcut Id="ApplicationDesktopShortcut"
Name="Myapp"
Description="Made by me"
Target="$(var.Myapp.TargetPath)Myapp.exe"
WorkingDirectory="APPLICATIONROOTDIRECTORY" />
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software\Myapp"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
</Directory>
...
and I have added the component:
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentRef Id="ApplicationShortcutDesktop"/>
</Feature>
The installation succesfully completes but no shortcut is created. What am I missing?
I think your Shortcut's 'Target' is wrong. You're passing it the build time source path. It should be something like "[APPLICATIONROOTDIRECTORY]Myapp.exe". See - wixtoolset.org/documentation/manual/v3/xsd/wix/shortcut.html
How do I create a shortcut on the desktop from a wix setup project?
The shortcut is a non-advertised one.
Remember to put the component in your feature tag.
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="ApplicationShortcutDesktop" Guid="*">
<Shortcut Id="ApplicationDesktopShortcut"
Name="Text under your icon"
Description="Comment field in your shortcut"
Target="[MYAPPDIRPROPERTY]MyApp.exe"
WorkingDirectory="MYAPPDIRPROPERTY"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software\MyCompany\MyApplicationName"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</Directory>
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="MyCompany" Name="MyCompany">
<Directory Id="MYAPPDIRPROPERTY" Name="MyAppName">
<!-- main installation files -->
</Directory>
</Directory>
</Directory>
</Directory>
I think my way is easier, no need for you to create a registry key:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" SourceName="Desktop" />
<Directory Id="MergeRedirectFolder">
<Component Id="MyExeComponent" Guid="{PUT-GUID-HERE}">
<File Id="MyExeFile" Source="$(var.ExeSourcePath)" KeyPath="yes">
<Shortcut
Id="DesktopShortcut"
Directory="DesktopFolder"
Name="$(var.ShortcutName)"
WorkingDirectory="MergeRedirectFolder" />
</File>
</Component>
</Directory>
</Directory>
Thanks for example. In WIX 3.8 it still raises:
"Error 3 ICE43: Component ... has non-advertised shortcuts. It should use a registry key under HKCU as its KeyPath, not a file."
So I did this such way in a file with features:
<Component Id="cmp79F6D61F01DD1060F418A05609A6DA70"
Directory="dirBin" Guid="*">
<File Id="fil34B100315EFE9D878B5C2227CD1454E1" KeyPath="yes"
Source="$(var.SourceDir)\FARMS.exe" >
<Shortcut Id="DesktopShortcut"
Directory="DesktopFolder"
Name="FARMS $(var.FarmsVersion)"
Description="Local Land Services desktop application"
WorkingDirectory="INSTALLFOLDER"
Icon="FARMS.exe"
IconIndex="0"
Advertise="yes" >
<Icon Id="FARMS.exe" SourceFile="$(var.SourceDir)\FARMS.exe" />
</Shortcut>
</File>
</Component>
And mentioned desktop folder in a file with product definition:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" Name="Desktop" />
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="FARMS" >
</Directory>
</Directory>
</Directory>
</Fragment>
It seems lot easier in this documentation.
First, you have to point your DesktopFolder,
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" Name="Desktop"/>
Then you should create Shortcut component for file that you want to create shortcut of.
<Component Id="PutYourComponentIdHere" Directory="FileDirectory" Guid="*">
<File Id="NotYourComponentId" KeyPath="yes" Source="..\YourFileSource\YourExecutable.exe">
<Shortcut Id="desktopServer" Directory="DesktopFolder" Name="YourShourtcutName" WorkingDirectory='WhereShouldYourShortcutPoint' Advertise="yes"/>
</File>
</Component>
It worked for me. I need to put icon but thats easy part. Hope it works.
After too much effort, I used this way:
<Product ...>
<Feature Id="ProductFeature" Title="SetupProject" Level="1">
...
...
<ComponentRef Id="cmpDesktopShortcut" />
</Feature>
<Component Id="cmpDesktopShortcut" Guid="PUT-GUID-HERE" Directory="DesktopFolder" >
<Shortcut Id="MyDesktopShortcut"
Name="Setup Project"
Description="Opens the program."
Directory="DesktopFolder"
Target="[INSTALLFOLDER]App.exe"
WorkingDirectory="INSTALLFOLDER"/>
<RegistryValue Root="HKCU" Key="Software\My Company\Sample Application" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Product>
I believe that using a "Current User" (HKCU) registry key as Key Path causes problems on a multi-user machine tool. Because the registry key is only created for the current user and when a different user logs in, then the auto-repair of the installation kicks in.
I want to add a shortcut in my program menu. i tried:
<Component Id='myId' Guid='E4DED108-0129-4a5b-83FE-C9D1E3025B00'>
<File Id='MyFileID' Name='Prog.exe' DiskId='1' Source='.\Prog.exe' KeyPath='yes'>
<Shortcut Id='myShortcut' Name='Prog' Icon='MyIcon.exe' IconIndex='0' Directory='ProgramMenuDir' Advertise='yes' />
</File>
</Component>
but the installer add the shortcut in a subfolder in the program menu! Why and what can i do to avoid this?
Thanks Micha
You can try to change Directory='ProgramMenuDir' into Directory='ProgramMenuFolder', otherwise make a seperate shortcuts component;
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramMenuFolder">
<Component Id="Shortcuts" Guid="{}">
<Shortcut Id='myShortcut' Name='Prog' Icon='MyIcon.exe' IconIndex='0' Directory='ProgramMenuFolder' WorkingDirectory='INSTALLDIR' Target="[INSTALLDIR]Prog.exe" />
<RegistryValue Root='HKCU' Key='SOFTWARE\prog\prog' Type='string' Value='1' KeyPath='yes' />
</Component>
</Directory>
<!-- other files -->
</Directory>
I have an app that is being installed with WiX 3 - most of the install works fine by now, but trying to get the desktop shortcut to work seems to cost me my mind...
I have my app being installed and I already have a shortcut on the Start Menu folder - works just fine. But how do I get the desktop shortcut up and running?
<Product Id="*" Name="....." UpgradeCode="MY-GUID">
<Package Id="*" InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="foobar.cab" EmbedCab="yes" />
<Property Id="ALLUSERS">1</Property>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="FooBar"/>
</Directory>
<Directory Id="DesktopFolder" SourceName="Desktop"/>
<Directory Id="ProgramFilesFolder">
<Directory Id="FoobarDir" Name="FOOBAR">
<Directory Id="INSTALLLOCATION" Name="FooApp">
<Component Id="MainFiles" Guid=".....">
<File Id="FooMainApp" Source="FooMainApp.exe" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
....
<!-- this shortcut here works just fine ... -->
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="AppShortcut" Guid="...">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="FooBarApp" Description="..."
Target="[INSTALLLOCATION]FooMainApp.exe"
WorkingDirectory="INSTALLLOCATION"/>
</Component>
</DirectoryRef>
<!-- but this shortcut here never seems to work .. ... -->
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut" Guid="....." >
<Shortcut Id="DesktopAppShortcut"
Advertise="no"
Name="FooBarApp" Description="...."
Target="[INSTALLLOCATION]FooMainApp.exe"
WorkingDirectory="INSTALLLOCATION"/>
</Component>
</DirectoryRef>
The errors I keep getting are:
ICE18: KeyPath for Component:
'DesktopShortcut' is Directory:
'DesktopFolder'. The
Directory/Component pair must be
listed in the CreateFolders table.
ICE38: Component DesktopShortcut
installs to user profile. It must use
a registry key under HKCU as its
KeyPath, not a file.
ICE43: Component
DesktopShortcut has non-advertised
shortcuts. It should use a registry
key under HKCU as its KeyPath, not a
file.
I do not understand what on earth WiX 3 / Windows Installer is trying to tell me here.... anyone??
Both components, AppShortcut and DesktopShortcut, are in fact part of the "main" feature - I don't see any issue there. I can't figure out what on earth could be wrong here....
Update: ok, so I added some registry key stuff to my desktop shortcut
<Component Id="DesktopShortcut" Guid="BF3587B4-F52E-411E-8814-CFCBF8201C0D">
<RegistryKey Root="HKCU" Key="Software\Foo Inc\FooBarApp\Installed"
Action="createAndRemoveOnUninstall">
<RegistryValue Name="DTSC" Value="1" Type="integer" KeyPath="yes"/>
</RegistryKey>
<Shortcut Id="DesktopShortcut" Directory="DesktopFolder"
Name="FooBar" WorkingDirectory="INSTALLLOCATION"
Icon="foobar.ico"
Target="[INSTALLOCATION]FooMainApp.exe"/>
</Component>
now the ICE messages are gone, but when I try to install the app, I get Error 1909 - the target folder doesn't exist, or you do not have permission to write to it (or something like that)
Update 2: the above sample code provided does work on Win XP, but it keeps failing on Win Server 2003 :-( Any further ideas??
Here's a working example from our live production code...
<Fragment>
<Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
<RegistryValue Id="RegShortcutDesktop" Root="HKCU"
Key="SOFTWARE\ACME\settings" Name="DesktopSC" Value="1"
Type="integer" KeyPath="yes" />
<Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]MyApp.exe"
Directory="DesktopFolder" Name="My Application"
Icon="$(var.product).ico" IconIndex="0"
WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
</Component>
</Fragment>
This is based on #saschabeaumont's answer, but hopefully with some extra helpful hints for us WiX beginners (is it a nightmare for everybody to learn???).
First, create a fragment that contains the shortcut details itself:
<Fragment>
<Component Id="DesktopShortcut" Directory="INSTALLFOLDER" Guid="*">
<RegistryValue Id="RegShortcutDesktop"
Root="HKCU"
Key="Software\Company\ApplicationName"
Name="DesktopSC"
Value="1"
Type="integer"
KeyPath="yes" />
<Shortcut Id="desktopSC"
Target="[INSTALLFOLDER]ApplicationName.exe"
WorkingDirectory="INSTALLFOLDER"
Icon="icon.ico"
Directory="DesktopFolder"
Name="ApplicationName"
Advertise="no"/>
</Component>
</Fragment>
Next, note that this fragment will need including in the Product element, like this:
<Feature Id="ProductFeature" Title="Your Application Title" Level="1">
...
<ComponentRef Id="DesktopShortcut" />
</Feature>
The ProductFeature will likely contain other fragments, such as files, and the program menu shortcut fragment.
Also, the DesktopFolder will need a reference in the TARGETDIR directory element (which will very likely contain other folders, such as ProgramMenuFolder as you require), like this:
<Directory Id="TARGETDIR" Name="SourceDir">
...
<Directory Id="DesktopFolder" Name="Desktop"/>
</Directory>
Each of these ICE messages is basically complaining about the same thing: a component installing a shortcut should have a registry entry as its keypath. To fix this, add something like this to the component:
<RegistryValue Root="HKCU" Key="Software\MyCompany\MyApplicationName"
Name="desktopShortcut" Type="integer" Value="1" KeyPath="yes"/>
The same goes for the component installing the start menu shortcut. Take a look at the related wix documentation sample about creating a shortcut.
My purpose is to create an internet shortcut link and put to desktop. Here is the code that works for me:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="09F1B63D-FB03-43FD-A326-FD49F93D00C8" Name="TestProduct" Language="1033" Version="0.0.0.1" Manufacturer="WixEdit" UpgradeCode="6B2F9AB4-73A6-45CB-9EC4-590D1AAA6779">
<Package Description="Test file in a Product" Comments="Simple test" InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Name="AAAA" Id="AAABBB">
<Component Id="AAAA">
<File Id="AAAA.EXE" Name="AAAA.exe" Source="U:\web\bin\x86\Release\AAAA.exe" />
</Component>
</Directory>
</Directory>
<Directory Id="DesktopFolder">
<Component Id="StartMenuShortcuts" Guid="E8EDD7BC-9762-4C3D-8341-FAEC983D318A">
<RemoveFolder Id="ProgramMenuDir" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" />
<util:InternetShortcut Id="WebsiteShortcut" Name="AAAA Website" Target="http://www.AAAA.com" />
</Component>
</Directory>
</Directory>
<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
<ComponentRef Id="StartMenuShortcuts" />
<ComponentRef Id="AAAA" />
</Feature>
<UI />
</Product>
</Wix>
NOTE: you need to add the following to your candle and light command lines: -ext WiXUtilExtension
Not sure if this was available back in 2010, but this is how I do it in WiX 3.7:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" SourceName="Desktop" />
<Directory Id="MergeRedirectFolder">
<Component Id="MyExeComponent" Guid="{PUT-GUID-HERE}">
<File Id="MyExeFile" Source="$(var.ExeSourcePath)" KeyPath="yes">
<Shortcut
Id="DesktopShortcut"
Directory="DesktopFolder"
Name="$(var.ShortcutName)"
WorkingDirectory="MergeRedirectFolder" />
</File>
</Component>
</Directory>
</Directory>
Following some example code on the net, I got my first WiX installer to work. However, it placed my program menu shortcut directly on Program Menus. I really want to create a folder, Sample, in Program Menus for my link.
Original Code:
<Shortcut Id="startmenuSample" Directory="ProgramMenuFolder" Name="Sample 0.5"
WorkingDirectory='INSTALLDIR' Icon="Sample.exe" IconIndex="0" Advertise="yes">
Attempt at modifying code (fails with compiler error):
<Shortcut Id="startmenuSample" Directory="ProgramMenuFolder\Sample" Name="Sample 0.5"
WorkingDirectory='INSTALLDIR' Icon="Sample.exe" IconIndex="0" Advertise="yes">
Note the addition of \Sample.
How do I go about adding that link to a new folder in the Program Menu?
This is a sample test I did, when I was asked to do the same thing
<Package InstallerVersion="200" Compressed="yes" />
<WixVariable Id="Manufacturer" Value="StackOverFlowHelper"/>
<WixVariable Id="ShortProduct" Value="ShortCuts"/>
<Media Id="1" Cabinet="WixShortCut.cab" EmbedCab="yes" />
<Icon Id="ShortCutIcon" SourceFile="YOUR.ico"/>
<!-- The icon that appears in Add & Remove Programs. -->
<Property Id="ARPPRODUCTICON" Value="ShortCutIcon" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ManufacturerFolder" Name="!(wix.Manufacturer)">
<Directory Id="INSTALLLOCATION" Name="!(wix.ShortProduct)">
<Component Id="ProductComponent" Guid="{YOUR_GUID}" KeyPath="yes">
<CreateFolder/>
</Component>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ProgramMenuManufacturer" Name="!(wix.ShortProduct)" />
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="ProgramFilesFolder">
<Component Id="ProgramMenuShortcuts" Guid="{YOUR_GUID}">
<CreateFolder Directory="ProgramMenuManufacturer"/>
<RemoveFolder Id="RemoveMenuShortcuts" Directory="ProgramMenuManufacturer" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\!(wix.Manufacturer)\!(wix.ShortProduct)" Name="InstalledStartMenuShortcuts" Type="integer" Value="1" />
</Component>
</DirectoryRef>
<DirectoryRef Id="INSTALLLOCATION" FileSource="Files">
<Component Id="WixShortCut" Guid="{YOUR_GUID}">
<File Id="Test.ShortCut" Vital="yes" Name="A_DOC.pdf" />
<CreateFolder />
<RegistryKey Root="HKCU" Key="Software\!(wix.Manufacturer)\!(wix.ShortProduct)" Action="createAndRemoveOnUninstall">
<RegistryValue Name="ShortCut" Value="1" Type="integer" KeyPath="yes"/>
</RegistryKey>
<!-- Shortcut in Start menu. -->
<Shortcut Id="ProgramMenuApplicationShortcut" Name="!(wix.ShortProduct)" Target="[#Test.ShortCut]"
Directory="ProgramMenuManufacturer" Show="normal" Icon="ShortCutIcon"/>
</Component>
</DirectoryRef>
<Feature Id="ProductFeature" Title="WixShortCuts" Level="1">
<ComponentRef Id="ProductComponent"/>
<ComponentRef Id="ProgramMenuShortcuts"/>
<ComponentRef Id="WixShortCut"/>
</Feature>
In Windows Installer you need to create a new directory under ProgramMenuFolder and then reference it.
<Directory Id="ProgramMenuFolder" >
<Directory Id="ProgramMenuDir" Name='My Folder'>
</Directory>
</Directory>
<Shortcut Id="startmenuSample" Directory="ProgramMenuFolder" Name="Sample 0.5"
WorkingDirectory='INSTALLDIR' Icon="Sample.exe" IconIndex="0" Advertise="yes">