WiX:如何重新启动Windows资源管理器以安装 /卸载shell扩展

我正在尝试编写一个包含托管图标 shell 扩展(使用 SharpShell)的 WiX 安装程序。我终于想出了如何通过 Wix 注册它(我无法让 SharpShell 注册管理器在通过 WiX 调用时工作)。

我正在尝试编写一个包含托管图标 shell 扩展(使用 SharpShell)的 WiX 安装程序。我终于想出了如何通过 Wix 注册它(我无法让 SharpShell 注册管理器在通过 WiX 调用时工作)。

在安装过程中,将出现以下对话框:

enter image description here

如果我选择“忽略”,则图标外壳扩展已成功安装,并且 Window Explorer 会立即获取更改。我不确定其检测为“正在使用”的文件。

在卸载过程中,将出现以下对话框:

Close applications prompt

如果您选择“自动关闭并尝试重新启动”选项,它将关闭 Windows 资源管理器,但它不会在安装结束时重新启动。我必须通过任务管理器手动重新启动它。

WiX 片段定义

定义 shell 扩展安装的 WiX 片段如下所示:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
    <!-- This fragment was originally generated using heat with the following command line:
            "$(WIX)bin\heat.exe" dir "$(SolutionDir)Icon ShellExtension\bin\$(ConfigurationName)" -dr IconShellExtensionDIR -cg IconShellExtension -var var.IconShellExtension.TargetDir -fips -g1 -gg -sfrag -srd -suid -template fragment -t "$(ProjectDir)AssemblyFileFilter.xslt" -out "$(ProjectDir)Fragments\IconShellExtension.wxs"
         
         It was then subsequently manually modified, as file associations are defined in a different component the default icon entry had to be removed.
    -->
    <Fragment>
    <DirectoryRef Id="IconShellExtensionDIR">
      <Component Id="IconShellExtension.dll" Guid="D609F6F2-52FB-4153-8D6A-3E2B7F8C4647">
        <Class Id="{A1C3600C-F3E5-300E-8167-541C62083DAA}" Context="InprocServer32" Description="IconShellExtension.UaProjectIconHandler" ThreadingModel="both" ForeignServer="mscoree.dll">
          <ProgId Id="IconShellExtension.UaProjectIconHandler" Description="UA Project File Icon Handler" />
        </Class>
        <util:RestartResource ProcessName="explorer.exe"/>
        <File Id="IconShellExtension.dll" KeyPath="yes" Source="$(var.IconShellExtension.TargetDir)\IconShellExtension.dll" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value="" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="Class" Value="IconShellExtension.UaProjectIconHandler" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="Assembly" Value="IconShellExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9e9ad08f31c5e4fb" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32\1.0.0.0" Name="CodeBase" Value="file:///[#IconShellExtension.dll]" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="Class" Value="IconShellExtension.UaProjectIconHandler" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="Assembly" Value="IconShellExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9e9ad08f31c5e4fb" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="CLSID\{A1C3600C-F3E5-300E-8167-541C62083DAA}\InprocServer32" Name="CodeBase" Value="file:///[#IconShellExtension.dll]" Type="string" Action="write" />
        <RegistryValue Root="HKCR" Key="UserAppProject\ShellEx\IconHandler" Value="{a1c3600c-f3e5-300e-8167-541c6208aa}" Type="string" Action="write" />
        <RegistryValue Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Explorer" Name="GlobalAssocChangedCounter" Value="1" Type="integer" Action="write" />
      </Component>
      <Component Id="SharpShell.dll" Guid="174E147D-4744-492F-BC5C-F00DAA4925AA">
        <File Id="SharpShell.dll" KeyPath="yes" Source="$(var.IconShellExtension.TargetDir)\SharpShell.dll" />
      </Component>
    </DirectoryRef>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="IconShellExtension">
      <ComponentRef Id="IconShellExtension.dll" />
      <ComponentRef Id="SharpShell.dll" />
    </ComponentGroup>
  </Fragment>
</Wix>
Goal

我希望安装程序能够安装或卸载,而不会提示用户有关正在使用的文件,并且它只是在此过程中自动关闭并重新启动 Windows 资源管理器。我的理解是这就是重新启动管理器所允许的,WixUtilsRestartResource标签应该为我做到这一点。

任何帮助都将不胜感激!

UPDATE

我已经尝试了各种不同的属性组合,并试图删除 / 禁用FilesInUse对话框。

我尝试按照this post中的建议设置以下属性组合:

    <Property Id="MSIRMSHUTDOWN" Value="2"/>
    <Property Id="MSIDISABLERMRESTART" Value="0"/>
    <Property Id="MSIRESTARTMANAGERCONTROL" Value="0"/>

这在卸载过程中执行了 explorer.exe 的重新启动,一旦卸载序列完成(尽管资源管理器关闭的时间长度很长)。但是,我发现当我尝试重新安装时,它再次显示 FilesInUse 对话框。

我找到了一个为我工作的解决方案,我将发布为接受的答案。

1

似乎有效且不显示任何不需要的对话框的最佳解决方案是删除MSIRMSHUTDOWNMSIDISABLERMRESTART属性并设置以下属性:

    <!-- The following setting seems to suppress any restart dialogs -->
    <Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable"/>

这干净地添加或删除了我的 shell 扩展。唯一的问题是,外壳扩展保持活动状态,直到我重新启动(因为这是一个图标外壳扩展,那么这是可以接受的我)。

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(126)
如何获得当前月份 (october month number)
上一篇
在将Flux转换为Mono时卡住了吗
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(45条)