WiX missing 'Start In' property in desktop shortcut - wix

I am working with WiX from last 5 month with no issues. Recently, i am in need to have "StartIn" property in App Desktop shortcut. By default, its empty.
Here is my full Installer code.
I am working with below code:
<Component Id="myapplication.EXE" DiskId="1" Guid="*">
<File Id="myapplication.EXE" Name="My Application.exe"
Source="D:\My Application\My Application.exe">
<Shortcut Id="desktopShortcut" Directory="DesktopFolder"
Name="My Application" WorkingDirectory="INSTALLDIR"
Icon="DesktopIcon.exe" IconIndex="0"
Description="My Application Description" />
<Shortcut Id="ExeShortcut" Directory="ProgramMenuDir"
Name="My Application" Icon="StartMenuIcon.exe" IconIndex="0" />
</File>
</Component>
But didn't work.
I have also tried adding "Target" property:
<Shortcut Target= "INSTALLDIR" Id="desktopShortcut" Directory="DesktopFolder"
Name="Virtual Sim Center Beta" WorkingDirectory="INSTALLDIR"
Icon="DesktopIcon.exe" IconIndex="0"
Description="My Application Description" />
but getting error message:
The Shortcut/#Target attribute cannot be specified when the Shortcut
element is nested underneath a File element.

This script bellow is working for my WIX:
....
<!-- Desktop Menu -->
<DirectoryRef Id="DesktopFolder">
<Component Id="FooDesktopShortcutMenu" Guid="*">
<Shortcut Id="FooApplicationDesktopShortcut"
Name="Foo Application"
Description="The Foo is Cool!"
Target="[#FooMainApp]"
WorkingDirectory="INSTALLFOLDER"
Directory="DesktopFolder"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\FooApplication"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
....
<!-- Tell Wix -->
<Feature Id="ProductFeature" Title="FooSetup" Level="1">
.....
<ComponentRef Id="FooDesktopShortcutMenu"/>
.....
</Feature>
.....

Glytzhkof is right and so is your WiX source - just put it under the Component.

In addition to the answer by #Adiono check whether the 'WorkingDirectory' folder actually contains the 'Target'.
The 'Start in' of my shortcut was blank even when both 'WorkingDirectory' and 'Target' had valid values, but the 'Target' was not present in the 'WorkingDirectory'.

I don't have Wix set up to try this, but you can try to move the Shortcut element up to be nested under the Component element and not the File element. Then set the WorkingFolder attribute. Try something like this.

Related

Wix: Adding Icon to the start menu application folder

I'm looking for a way to add an icon to the start menu application folder using Wix. I already know how to add icons for shortcuts but the application folder doesn't appear to be a shortcut. Any help would be appreciated. Thanks.
Since you haven't shared any code, there is an example
<Component Id="MainAppFile" Guid="*">
<File Id="MainAppExecutable" Source="$(var.AppDir)$(var.AppFile)" KeyPath="yes">
<Shortcut Id="StartMenuAppShortcut"
Name="$(var.ProductName)"
Advertise="yes"
Directory="ApplicationProgramsFolder"
WorkingDirectory="INSTALLLOCATION">
<Icon Id="StartMenuIcon.ico" SourceFile="..\icon.ico"/>
</Shortcut>
<Shortcut Id="DesktopAppShortcut"
Name="$(var.ProductName)"
Advertise="yes"
Directory="DesktopFolder"
WorkingDirectory="INSTALLLOCATION" >
<Icon Id="DesktopIcon.ico" SourceFile="..\icon.ico"/>
</Shortcut>
</File>
<RemoveFolder Id="CleanupAppShortcut" Directory="ApplicationProgramsFolder" On="uninstall"/>
</Component>

Wix recreate deleted shortcut when reinstalling

I'm learning about shortcuts in Wix and have managed to create shortcuts on the desktop.
If I delete the shortcut and then run the installer again I would like the shortcut to be created again.
How can this behavior be achieved with Wix?
I have created shortcuts both with
<File Id="TestX.exe" Name="TestX.exe" Source="$(var.TestX_TargetDir)TestX.exe">
<Shortcut Id="desktopIcon" Directory="DesktopFolder" Name="TestX" WorkingDirectory='INSTALLFOLDER' Icon="IconTestX.exe" IconIndex="0" Advertise="yes" />
</File>
and
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="DesktopShortcut"
Guid="1E0D1741-57F0-4E22-89FC-4A189E2BB7E0">
<Shortcut Id="desktopSC"
Name="MyProduct"
Description="MyProduct description"
Target="[INSTALLFOLDER]TestX.exe"
Icon="IconTestX.exe">
</Shortcut>
<RemoveFolder Id="RemoveDesktopFolder"
Directory="DesktopFolder"
On="uninstall" />
<RegistryValue Root="HKCU"
Key="Software\[Manufacturer]\[ProductName]"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes" />
</Component>
</DirectoryRef>
</Fragment>
I solved this problem by using WixUI_InstallDir in the WixUI library, which added a GUI which includes the option to start a repair.
Links about the WixUI dialog library:
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_dialog_library.html
http://wixtoolset.org/documentation/manual/v3/wixui/dialog_reference/wixui_installdir.html

Set shortcut targetpath Wix

I want to set the shortcut target path in wix for an advertised shortcut
This is the code that creates the shorcut now:
<Component Id="APP_EXE" Directory="INSTALLDIR" DiskId="1" Guid="XXXX-XXXX">
<File Id="AppExe" Name="app.exe" Source="$(var.ComponentSourceDir)\$(var.ExeName)" KeyPath="yes">
<Shortcut Id="desktopShortcut" Advertise="yes" Directory="DesktopFolder" Name="$(var.VersionedName)" WorkingDirectory="INSTALLDIR" Icon="MainIcon.exe" IconIndex="0" />
</File>
</Component>
The target in shortcut properties window is readonly now and it displayes the application name. I cannot change it.
I created a new component where I create the shortcut. I removed the previous one.
<Component Id="APP_EXE" Directory="INSTALLDIR" DiskId="1" Guid="XXXX-XXXX">
<File Id="AppExe" Name="app.exe" Source="$(var.ComponentSourceDir)\$(var.ExeName)" KeyPath="yes">
</File>
</Component>
<Component Id="APP_SHORTCUT" Directory="INSTALLDIR" DiskId="1" Guid="XXXX_XXXXX">
<RegistryValue Root="HKCU" Key="Software\APP\Installer" Name="desktopShortcut" Value="KeyPath" KeyPath="yes" Type="string" />
<Shortcut Id="desktopShortcut" Directory="DesktopFolder" Name="$(var.VersionedName)" WorkingDirectory="INSTALLDIR" Icon="MainIcon.exe" IconIndex="0" Target="[INSTALLDIR]app.exe"/>
</Component>

Shortcut Target is set to keyPath instead of parent file? (WIX documentation is wrong)

WIX documentatino on Shortcut element says about Target attribute:
The value will be defaulted to the parent File when nested under a File element.
But the code
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll" KeyPath="yes" />
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
</Component>
does not work as expected - shortcut points to dll file and running it shows Windwos error message that it can't launch file with dll extention.
To fix that we need to make the only difference: set KeyPath="yes" attribute for exe file instead of dll:
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll"/>
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" KeyPath="yes" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
</Component>
So WIX documentation contains mistake? Target is set not to the parent File element, but to the ancestor's Component's KeyPath?
Or is it my mistake and something wrong with my code?
Try to add a <RegistryValue> tag like this:
<Component Guid="MY_GUID" Id="MyAppComponent">
<File Source="SomeDll.dll" Name="SomeDll.dll" Id="SomeDll.dll"/>
<File Source="MyDll.exe" Name="MyDll.exe" Id="MyDll.exe" KeyPath="yes" />
<Shortcut Id="MyApp.Shortcut" Directory="ApplicationProgramMenuDir" WorkingDirectory="INSTALLDIR" Name="MyApp" Icon="ProgramIcon.ico" Advertise="yes" />
</File>
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\setup" Name="Shortcut" Type="integer" Value="1" KeyPath="yes" />
</Component>
If your InstallScope is perUser, using HKCU
If your InstallScope is perMachine, using HKLM

wix - shortcut icon for website

I'm new on wix. In need to create a shortcut to a local website.
It works fine and creates the shorcuts, but it doesn't show any icon on start menu and desktop... The website has favicon file and when I open the site I can see it perfectly - I just don't see it in the shortcut. I tried to google it but I didn't find a good answer for util:InternetShortcut..
My code is:
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcutBBBApp" Guid="---">
<util:InternetShortcut Id="ApplicationStartMenuShortcutBBBApp"
Name="BBB"
Target="http://localhost/BBB"/>
<util:InternetShortcut Id="ApplicationDesktopShortcutBBBApp"
Name="BBB"
Directory="DesktopFolder"
Target="http://localhost/BBB"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\BBB" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
There is an easier solution for that problem. Instead of using InternetShortcut, you can just use the normal Shortcut and use a trick to set the target being a url.
<SetProperty Id="URL" Value="http://yourpage.com" Sequence="execute" Before="CreateShortcuts" />
<Shortcut Directory="DesktopFolder" Id="WebShortcut" Name="Your Page" Description="Your Page Description" Target="[URL]" Icon="IconDesktop">
<Icon Id="IconDesktop" SourceFile="images\icon.ico" />
</Shortcut>
"SetProperty" can be placed somewhere in your Product tag.
"Shortcut" should be placed instead of "InternetShortcut".
It is important to have the property [URL] as a Target. As a Property it can be an url. Diretctly written it doese not work.
There might be warnings in heat/candle/light, they can be ignored.
InternetShortcut doesn't support specifying an icon like a normal Shortcut. There's an open feature request for that. Technically, IUniformResourceLocator shortcuts in Windows don't support icons, though IShellLink shortcuts do.
A little late answering this, but just needed to do the same thing. The approach I took was to use the iniFile element to write out a url file.
Two points of interest with this approach:
Since the shortcut is on the desktop and the icon file is located elsewhere on the file system, I needed to create separate components to deploy the icon file.
If the MSI is ran as a normal user with UAC turned on, the icon is not set for the shortcut. Once I disabled UAC prior to installing, the icon was set correctly.
<Fragment>
<DirectoryRef Id="DesktopFolder">
<Component Id="ProductInternetShortcut" Guid="{YOUR_GUID_HERE}" >
<IniFile Id="url_name"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="URL"
Value="https://my.url.com/" />
<IniFile Id="url_target"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="Target"
Value="https://my.url.com/" />
<IniFile Id="url_idlist"
Action="createLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IDList"
Value=" " />
<IniFile Id="url_HotKey"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="HotKey"
Value="0" />
<IniFile Id="url_icon"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IconFile"
Value="PATH_TO_ICON_FILE_ON_WORKSTATION" />
<IniFile Id="url_iconIndex"
Action="addLine"
Directory="DesktopFolder"
Section="InternetShortcut"
Name="ProductInternetShortcut.url"
Key="IconIndex"
Value="0" />
<RegistryValue Root="HKCU" Key="Software\COMPANY\PRODUCT" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="ProductFolder">
<Component Id="ShortcutIcons" Guid="{YOUR_GUID_HERE}">
<File Id="filProductIcons" KeyPath="yes" Source="PATH_TO_ICON_FILE_ON_DEVELOPER_MACHINE" />
</Component>
</DirectoryRef>
</Fragment>
In Wix you can create an InternetShortcut with an icon via the InternetShortcut Element (Util Extension).
Below is an example from an app I'm working on of adding a link to a website with an icon via the <InternetShorcut> element and placing that link on both the Desktop and the Start Menu.
Note, you may have to put the "util" prefix in front of the element name like so although I didn't have to do that: <util:InternetShortcut>.
<Directory Id="ProgramMenuFolder" Name="ProgramMenuFolder">
<Directory Id="ProgramMenuFolder.MyApplicationName" Name="MyApplicationName">
<Component Id="Component.Uninstall" Guid="215c7bec-7967-43e6-8f01-72c27fbb2a98">
<CreateFolder/>
<RemoveFolder Id="ProgramMenuFolder.MyApplicationName" On="uninstall"/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
<Component Id="InternetShortcut" Guid="215c7bec-7967-43e6-8f01-72c22e505f09">
<InternetShortcut
IconFile="[INSTALLDIR]\icon.ico"
IconIndex="0"
Name="Admin Page"
Id="InternetShortcut"
Target="http://localhost:4444"
Type="link"
xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
</Directory>
</Directory>
<Directory Id="DesktopFolder" Name="DesktopFolder">
<Component Id="InternetShortcut.1" Guid="B27DF351-6EDA-4BEF-A3AC-F12313260203">
<InternetShortcut
IconFile="[INSTALLDIR]\icon.ico"
IconIndex="0"
Name="Admin Page"
Id="InternetShortcut.1"
Target="http://localhost:4444"
Type="link"
xmlns="http://schemas.microsoft.com/wix/UtilExtension"/>
<CreateFolder/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplicationName">
<RegistryValue Value="0" Type="string" KeyPath="yes"/>
</RegistryKey>
</Component>
</Directory>
<Feature Id="Complete" Title="Complete" Absent="allow" Level="1">
<ComponentRef Id="InternetShortcut"/>
<ComponentRef Id="InternetShortcut.1"/>
</Feature>
Also, see How To: Create a Shortcut to a Webpage