1

We have recently removed the Advertised property to our installation since all the icon was standard ones (generic/blank) after installing. Now we use this kind of code:

<DirectoryRef Id="MyAppShortcutFolder">
    <Component Id="MyAppShortcuts" DiskId="1" Guid="MyGuid">
        <CreateFolder />
        <RegistryKey Action="createAndRemoveOnUninstall" Root="HKCU" Key="$(var.MyAppRegKey)\Shortcuts">
            <RegistryValue Name="ClientShortcuts" Value="yes" Type="string" KeyPath="yes" />
        </RegistryKey>
        <Shortcut Id="MyAppShortcut" Directory="MyAppShortcutFolder" 
            Name="!(loc.ShortcutMyAppName)"
            WorkingDirectory="MYAPPINSTALLDIR"
            Target="[MYAPPINSTALLDIR]MyApp.exe"
            Arguments='xxx"'
            Icon="ARPPRODUCTICON.exe" />
        <RemoveFolder Id='RmdirClientShortcutFolder' Directory='MyAppShortcutFolder' On='uninstall' />
    </Component>
...
<Icon Id="ARPPRODUCTICON.exe" SourceFile="$(var.MyAppBasePath)\ICO\MyAppShortcut.ico" />

This produce a shortcut that points to an icon installed somewhere like "%systemroot%/A-GUID-Here/ARPPRODUCTICON.exe". This work fine as long as the shortcut is not copied to the desktop. If the user does this (very common actually) and then later installs a new version of our software (probably a "major" update) the old shortcut icon is uninstalled and a new GUID is created for the new shortcut icon. This makes the (old) desktop shortcut lose its icon.

What we really want is to point out the icon from the built in resource of the MyApp.exe. If this is not possible we would like the shortcut icon to reference a permanent location so that the old shortcut still works after an upgrade. We have maybe 10 shortcuts in the install. We could create a special resource DLL/EXE for just storing the ICON resource if necessary. But how to we make the short point out a "locally" installed file instead of %systemroot%?

We use Wix 3.5. We must support Windows XP/2003.

Regards Aldus

helb
  • 7,609
  • 8
  • 36
  • 58
  • Maybe an explanation of an option is needed: If I want to install my ICO files in the same directory as my application. How do I reference that ICO file instead of something that will be put in %systemroot%/GUID as an Icon for my shortcut? – Aldus-Monitor Oct 15 '14 at 09:43
  • To fix the install location of the Icon using a GUID that does not change on upgrade/reinstall would also be acceptable. Is this possible? How? – Aldus-Monitor Oct 21 '14 at 07:09

2 Answers2

1

A permanent location for the ico file won't fix another problem in that the shortcut the user copied to the desktop will still point at the wrong EXE file.

One approach I've used in the past to maintain a stable program shortcut to a file that moves around or changes names is to create a very small stub EXE under your main app folder for the shortcut to point at. When run, the stub uses runtime logic to find the real EXE and then shells it. For example, in your case, you might write a registry entry with the GUID so the stub knows where to find the EXE. If your other EXE is large or slow to load / initialize, then you can add a splash screen to your stub and get a quicker UI response experience for the user at the same time.

Ian Crane
  • 21
  • 5
  • Typically our users install to a fixed location and this location never changes and the EXE-name is also the same. It would be acceptable to lose the desktop shortcut in the very rare case where the users changes install directory. But for me the problem is that an Icon in the Icon table always ends up in a random GUID location on each install. This makes the user made shortcut lose its icon each upgrade (normally 4 times per year) but not its function. If the icon file would keep its GUID after an upgrade it would also be acceptable solution. – Aldus-Monitor Oct 21 '14 at 07:06
0

If you do not specify the Icon attribute for the Shortcut element, the shortcut is created with the first icon found in the target exe file.

I am on Windows 10 and using WiX 3.10 with shortcuts that have advertised="yes" but I disable advertising them with:

<Property Id="DISABLEADVTSHORTCUTS" Value="1" />

Also see this answer.

Community
  • 1
  • 1
helb
  • 7,609
  • 8
  • 36
  • 58