<DirectoryRef Id='ProgramMenuFolder'> <Component Id='cmpStartMenuShortcut' Guid='MY GUID HERE'> <Shortcut Id='StartMenuShortcut' Name='$(var.ProductName)' Icon='MainIcon.ico' Description='$(var.ProductName)' Target='[ClientDir]myapp.exe' WorkingDirectory='ClientDir'/> <RegistryValue Action='write' Type='integer' Root='HKCU' Key='Software\Company\Product Name' Name='installed' Value='1' KeyPath='yes'/> </Component> </DirectoryRef>
由于我的安装是每台机器(ALLUSERS = 1,Package / @ InstallPrivileges =’raised’和@ InstallScope =’perMachine’),所以ProgramMenuFolder是机器上所有用户的文件夹.
我的问题与注册表值有关.我的理解是,需要为包含快捷方式的组件提供一个KeyPath.样本使用HKCU,它是每个用户的位置.
将每个用户的值用作每个机器组件的KeyPath是不是一个错误?
如果一台机器有两个管理员,并且admin#1安装该产品,并且admin#2尝试修复,那么Windows Installer将不会看到注册表值,并认为该快捷方式丢失,并且将安装一个重复的对象?
所以我尝试将RegistryValue / @ Root更改为HKLM,但是WiX抱怨:
error LGHT0204 : ICE38: Component cmpStartMenuShortcut installs to user profile. It’s[sic] KeyPath registry key must fall under HKCU.
error LGHT0204 : ICE43: Component cmpStartMenuShortcut has non-advertised shortcuts. It’s[sic] KeyPath registry key should fall under HKCU.
error LGHT0204 : ICE57: Component ‘cmpStartMenuShortcut’ has both per-user and per-machine data with a per-machine KeyPath.
我不明白为什么这个密钥必须在HKCU下.