Wix为所有用户/每台机器创build不公开的快捷方式

在WIX中,如何在allusersconfiguration文件中创build一个非公布的快捷方式? 到目前为止,我只能用广告的快捷方式来完成这个任务。 我更喜欢非广告快捷方式,因为您可以转到快捷方式的属性并使用“查找目标”。

在我看到的教程中,使用registry值作为快捷键的键盘path。 问题是他们使用HKCU作为根源。 当使用HKCU,并且另一个用户卸载该程序(因为它为所有用户安装)registry项被留下。 当我使用HKMU作为根时,我得到一个ICE57错误,但是当其他用户卸载程序时,这个键被删除。 尽pipeHKMU看起来行为正确(每个用户或所有用户),但我似乎被推向使用HKCU。

当我尝试创build非广告快捷方式时,我得到各种ICE错误,如ICE38,ICE43或ICE57。我见过的大多数文章都build议“忽略冰错误”。 必须有一种方法来创build非广告快捷方式,而不会产生ICE错误。

请发表示例代码。

对不起,如果这是不好的礼仪回答我自己的问题。

最近我偶然发现了关于DISABLEADVTSHORTCUTS属性的信息。 我创build了一个带有广告快捷方式的安装,并将DISABLEADVTSHORTCUTS属性设置为1,从而生成非广告快捷方式。 这绕过了ICE43错误,因为广告的快捷方式可以使用文件作为关键path。 由于DISABLEADVTSHORTCUTS已设置,Windows Installer将使用常规快捷方式replace这些广告快捷方式。

我将Package元素的 InstallScope属性设置为“perMachine”。 这将ALLUSERS属性设置为1.然后ProgramMenuFolder和DesktopFolder的值将parsing为所有用户configuration文件。

对于在ProgramMenuFolder下创build的文件夹,有一个RemoveFolder和RegistryValue元素。 我见过的例子( ex1 , ex2 )使用HKCU作为RegistryValue的根。 我把这个根改成了HKMU ,根据ALLUSERS的值,它parsing成HKCU或HKLM。

简而言之,在DISABLEADVTSHORTCUTS设置为1的情况下,您的广告快捷方式不会产生ICE错误,但在安装后会转换为非广告快捷方式。 只要不是非广告快捷方式的键path,使用根HKMU的RegistryValue就可以适用于KeyPath。

<?xml version="1.0" encoding="utf-8"?> <!-- This example is based on SampleFirst by Gábor DEÁK JAHN, Tramontána: http://www.tramontana.co.hu/wix/lesson1.php#1.3 Original SampleFirst: http://www.tramontana.co.hu/wix/download.php?file=samples/samplefirst.zip&type=application/zip --> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Name="Foobar 1.0" Id="YOURGUID-21F1-4026-ABD2-7CC7F8CE4D18" UpgradeCode="YOURGUID-AFA4-46C6-94AA-EEE3D104F903" Language="1033" Codepage="1252" Version="1.0.0" Manufacturer="Acme Ltd."> <Package Id="*" Keywords="Installer" Description="Acme's Foobar 1.0 Installer" Comments="Foobar is a registered trademark of Acme Ltd." Manufacturer="Acme Ltd." InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" InstallScope="perMachine" /> <Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" /> <Property Id="DiskPrompt" Value="Acme's Foobar 1.0 Installation [1]" /> <Property Id="DISABLEADVTSHORTCUTS" Value="1" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder" Name="PFiles"> <Directory Id="Acme" Name="Acme"> <Directory Id="INSTALLDIR" Name="Foobar 1.0"> <Component Id="MainExecutable" Guid="YOURGUID-3E4F-47A2-86F1-F3162E9C4798"> <File Id="FoobarEXE" Name="FoobarAppl10.exe" DiskId="1" Source="FoobarAppl10.exe" KeyPath="yes"> <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" /> <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" /> </File> </Component> <Component Id="HelperLibrary" Guid="YOURGUID-C7DA-4C02-A2F0-A6E089FC0CF3"> <File Id="HelperDLL" Name="Helper.dll" DiskId="1" Source="Helper.dll" KeyPath="yes" /> </Component> <Component Id="Manual" Guid="YOURGUID-FF92-4BF4-A322-819A3B2265A0"> <File Id="Manual" Name="Manual.pdf" DiskId="1" Source="Manual.pdf" KeyPath="yes"> <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" /> </File> </Component> </Directory> </Directory> </Directory> <Directory Id="ProgramMenuFolder" Name="Programs"> <Directory Id="ProgramMenuDir" Name="Foobar 1.0"> <Component Id="ProgramMenuDir" Guid="YOURGUID-D1C2-4D76-BA46-C6FA79862E77"> <RemoveFolder Id="ProgramMenuDir" On="uninstall" /> <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" /> </Component> </Directory> </Directory> <Directory Id="DesktopFolder" Name="Desktop" /> </Directory> <Feature Id="Complete" Level="1"> <ComponentRef Id="MainExecutable" /> <ComponentRef Id="HelperLibrary" /> <ComponentRef Id="Manual" /> <ComponentRef Id="ProgramMenuDir" /> </Feature> <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" /> </Product> </Wix> 

看一下从MSI到WiX,第10部分 – Alex Shevchuk的快捷方式 。

或者Rob Menching的博客文章如何创build卸载快捷方式(并通过所有的ICEvalidation)。

基本上ICE57是相当恼人的…但这里的(似乎是工作)我用于桌面快捷方式的代码:)

 <Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*"> <RegistryValue Id="RegShortcutDesktop" Root="HKCU" Key="SOFTWARE\My App\1.0\settings" Name="DesktopSC" Value="1" Type="integer" KeyPath="yes" /> <Shortcut Id="desktopSc" Target="[APPLICATIONFOLDER]MyApp.exe" Directory="DesktopFolder" Name="My Applications" Icon="myapp.ico" IconIndex="0" WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/> <RemoveFolder Id="RemoveShortcutFolder" On="uninstall" /> <Condition>DT_SHORTCUT=1</Condition> </Component> 

虽然这篇文章比较老,但是它包含了相当有用的信息,而且看起来还很活跃 我想指出,一般来说,你不需要一个虚拟的registry键为您的快捷方式! AFAIK这是WiX教程thingy,不是MSI或authentication要求。 这是一个没有注册码的例子:

 <Fragment Id="Folders"> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLFOLDER" Name="MyApp"> </Directory> </Directory> <Directory Id="ProgramMenuFolder"> <Directory Id="MyAppStartMenuDir" Name="MyApp"/> </Directory> </Directory> </Fragment> <Fragment Id="Components"> <Component Id="MyAppComp" Directory="INSTALLFOLDER" ...> <!--The advertise flag below is to bypass ICE errors in WiX, the actual shortcut will not be advertises if those are disabled globally with DISABLEADVTSHORTCUTS--> <File ..." KeyPath="yes"> <Shortcut Id="MyAppStartMenuLink" Directory="MyAppStartMenuDir" Advertise="yes" ... /> </File> <RemoveFolder Id="StartMenuDirRemoved" Directory="MyAppStartMenuDir" On="uninstall" /> </Component> </Fragment> 

请注意,这会将您的快捷方式与可执行文件放在一个组件中。 如果这麻烦你然后使用虚拟registry项(如在很好地解释接受自我答案)。

Interesting Posts