I am trying to create multiple shortcuts that are installed with my application. For an unknown reason, one is missing from the Start Menu and I can’t figure out why.
We create a new version in format "7.8.9.subversion_revision_number" for every build. On each build, we assign a new random UpgradeCode
to the <Product>
element (mostly because UpgradeCode="*"
is invalid).
Each version must be installed independently from each other. I want the shortcuts to be associated only this specific current version installed. They should be removed if the version is uninstalled. They should not be modified if a future version is installed. The life cycle of the shortcuts must follow the specific version that was installed.
Most online examples and official documentation suggest to use Guid="PUT-GUID-HERE"
in the <Component>
definition. This is a problem for me. We release our application once or twice per year. When a developer will be assigned to update the installer, he/she will likely forget to generate a new guid for the shortcuts component.
I would prefer to use Guid="*"
in the <Component>
definition. The less human intervention when creating a new release, the better.
The Component documentation about the Guid attribute states :
*
indicates that the linker should generate a stable guid. Generatable guids are supported only for components with a single file as the component's keypath or no files and a registry value as the keypath.
Since I do have multiple shortcuts file (*.lnk files) in my component, I am using a <registry>
element as keypath. The path of the registry is "version based" to make it "unique per version". For example :
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\[ProductVersion]" Name="installed_extra_links" Type="integer" Value="1" KeyPath="yes"/>
If I understand this correctly, because the keypath is "unique in each version", a stable GUID should be generated and it should also be unique per "version" (per build).
Here is the problem.
- If I install version 7.8.9.100, all shortcuts are available in the Start Menu.
- If I install version 7.8.9.101, then my "Foobar Command Prompt" is not visible in the Start Menu. Other shortcuts are fine.
- If I install version 7.8.9.102, then (again) my "Foobar Command Prompt" is missing from in the Start Menu. Other shortcuts are fine.
The *.lnk files are correctly created. For example, file "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Foobar v7.8.9.102 \Foobar Command Prompt.lnk" is created and working but missing from Start Menu.
What is so special about the "Foobar Command Prompt" shortcut ? Is that Windows that is hiding the shortcut for a weird reason ?
Here is my definition of my shortcuts:
<!-- Define shortcuts that will be added to the Start Menu directory -->
<DirectoryRef Id="START_MENU_DIR">
<Component Id="FOOBAR_SHORTCUTS" Guid="*">
<Shortcut Id="BinDirectoryShortcut"
Name="Binary files"
Target="[INSTALL_BIN_DIR]"/>
<Shortcut Id="CommandPromptShortcut"
Name="Foobar Command Prompt"
WorkingDirectory="INSTALL_BIN_DIR"
Target="[SystemFolder]cmd.exe"/>
<Shortcut Id="PrepareConfigShortcut"
Name="Prepare configuration"
WorkingDirectory="INSTALL_ROOT_DIR"
Target="[INSTALL_ROOT_DIR]prepare_configuration.bat"/>
<Shortcut Id="OpenFoobarShortcut"
Name="Open Foobar GUI"
WorkingDirectory="INSTALL_BIN_DIR"
Target="[INSTALL_BIN_DIR]foobar_gui.exe"/>
<!-- Delete shortcuts directory on uninstall -->
<RemoveFolder Id="START_MENU_DIR" On="uninstall"/>
<!-- Use a custom registry value as keypath -->
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\[ProductVersion]"
Name="installed_extra_links" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
Note: I might be incorrect in using Guid="*"
in the definition of the Component element but I have also observed that CMake/CPack 3.22.0 is also doing this (here and here) when building an MSI with multiple shortcuts.
I am installing on Windows Server 2016 Standard.