问题
I want to make a wix installer, with an optional desktop shortcut for all users. Optional means, I cannot put it in the component
of the main exe, but in a separate component
, so that I can set a separate feature
for the shortcut.
When doing this, wix complains:
error LGHT0204 : ICE38: Component DesktopShortcut installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.
So I set an aditional registry key like this:
<Component Id="DesktopShortcut" Guid="767f3e19-9a7d-4793-9782-75516494a57c">
<Shortcut Target="[APPLICATIONROOTDIRECTORY]ocean.exe" Id="OceanShortcutDesktop" Name="$(var.ProductName)" WorkingDirectory='APPLICATIONROOTDIRECTORY' Icon="OceanIcon"/>
<RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]\installs' Name="desktopshortcut" Type='string' Value='' KeyPath='yes' />
</Component>
The shortcut goes in "All Users" since I set the ALLUSERS=1 property. However, there is no equivalent for registry, and the key goes in the current (installing) user registry. This is IMHO an issue : if the user profile gets deleted, the shortcut will not be deleted anymore on uninstall.
Using "HKLM" instead causes an error in wix (mixing per-user and per-machine):
error LGHT0204 : ICE38: Component DesktopShortcut installs to user profile. It's KeyPath registry key must fall under HKCU.
This is quite stupid from wix, as "All Users" component should be linked to the machine, and not to a normal user, as there is no "all users" registry.
Any idea?
回答1:
You can try to change the registry root to 'HKMU' (From what I remember it's supposed to to write to the HKEY_LOCAL_MACHINE when the install is per-machine and under HKEY_CURRENT_USER when its not).
If you change the root to 'HKMU' you will get the ICE57 error (Component 'DesktopShortcut' has both per-user data and a keypath that can be either per-user or per-machine.)
You can suppress this error and the installer will create all-users shortcut (It worked when I tried it, but I'm not sure it's the best way to do this).
(To disable the ICE57 error see: How to fix ICE57.Per-User installation)
来源:https://stackoverflow.com/questions/17319466/install-optional-desktop-shortcut-for-all-users