2015-06-19 60 views
2

我正在使用Wix 3.9和Wix-edit 0.7.5/Notepad ++为我的应用程序创建MSI安装程序。我想在安装的文件夹中创建一个卸载快捷方式。例如:WIX - 在已安装文件夹中创建卸载快捷方式

C:\MySoftware\Uninstall.lnk 

我尝试了一些东西,但在所有的情况下,当我通过链接卸载该软件,程序文件夹C:\MySoftware不会被删除。卸载其他方式按预期工作。

首先,我试图将其创建为<Directory>标签中的组件。在我看来有点哈克,因为我必须补充<CreateFolder>

<Directory Id="MYINSTALLDIR" Name="MySoftware"> 
    <!-- my files... --> 

    <Component Id="ABC" Guid="PUT-GUID-HERE"> 
     <CreateFolder/> <!-- have to add this --> 
     <Shortcut Id="UninstallProduct" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]"/> 
    </Component> 

</Directory> 

<Feature Id="DefaultFeature" Title="Main Feature" Level="1"> 
    <!-- some references... --> 
    <ComponentRef Id="ABC" /> 
</Feature> 

我也试图与<RemoveFolder Id="MYINSTALLDIR" On="uninstall" />,相同的结果替代<CreateFolder/>

闯闯:

<DirectoryRef Id="ApplicationProgramsFolder"> 
    <Component Id="StartMenuShortcuts" Guid="*"> 
     <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" /> 
     <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" /> 
     <Shortcut Id="UninstallProduct1" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]"/> 
     <Shortcut Id="UninstallProduct2" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]" Directory="MYINSTALLDIR" /> 
    </Component> 
</DirectoryRef> 

这里,除了具有同样的结果,我建立的时候得到一个警告:file.wxs(31) : warning LGHT1076 : ICE57: Component 'StartMenuShortcuts' has both per-user and per-machine data with an HKCU Registry KeyPath.

如何在不影响卸载行为的情况下创建可以使用的快捷方式?我不知道它是否有所作为,但我需要这个工作没有管理员权限(我使用<Package ... InstallScope="perUser" InstallPrivileges="limited">)。

我知道我可以创建一个.lnk文件并将其添加到项目中,但我不喜欢,因为那样我就不必担心在每个项目上更新它的GUID。

+0

检查行动RemoveShortcuts和RemoveRegistryValues被RemoveFolders之前调度。你可以使用Orca来做到这一点。 – Marlos

+0

在Orca中,“InstallExecuteSequence”条目有几个操作,然后依次为“RemoveRegistryValues”,“RemoveShortcuts”和“RemoveFiles”。当我通过快捷方式卸载时,Windows是否会将“.lnk”文件打开?因为当我通过开始菜单链接或控制面板卸载时,我看不到这种行为。 –

+0

你的假设确实有道理。我会调查是否在我的电脑中出现同样的情况。 – Marlos

回答

3

发生此问题的原因是您没有为msiexec设置工作目录,然后它将使用当前目录,引发错误2911(无法删除文件夹)。

参考添加到WindowsFolder

<Directory Id="MYINSTALLDIR" Name="MySoftware"> 
    ... 
    <Directory Id="WindowsFolder" Name="WindowsFolder" /> 
</Directory> 

然后修改您的快捷方式添加属性WorkingDirectory="WindowsFolder"

<Shortcut Id="UninstallProduct" Name="Uninstall MySoftware" 
      Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" 
      Arguments="/x [ProductCode]" WorkingDirectory="WindowsFolder" /> 
+0

太棒了!非常感谢! –

相关问题