繁体   English   中英

wix uninstaller(exe)如何自行删除

[英]How wix uninstaller(exe) can remove itself

我有自定义安装程序和卸载程序,它将MSI和其他资源安装到PC。 卸载过程在以下行中有效:

<DirectoryRef Id="TARGETDIR">
    <Component Id="AddRemovePrograms" Guid="*" KeyPath="yes">
      <RegistryValue Id="ARPEntry1" Type="string" Action="write" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ProductCode)" Name="DisplayName" Value="$(var.ProductName)"/>
      <RegistryValue Id="ARPEntry2" Type="string" Action="write" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ProductCode)" Name="DisplayVersion" Value="$(var.ProductVersion)"/>
      <RegistryValue Id="ARPEntry3" Type="string" Action="write" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ProductCode)" Name="Publisher" Value="$(var.Manufacturer)"/>
      <RegistryValue Id="ARPEntry4" Type="integer" Action="write" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ProductCode)" Name="NoModify" Value="1"/>
      <RegistryValue Id="ARPEntry5" Type="string" Action="write" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ProductCode)" Name="UninstallString" Value="[CommonAppDataFolder]\[Manufacturer]\[ProductName]\Uninstaller.exe"/>
      <RegistryValue Id="ARPEntry6" Type="string" Action="write" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\$(var.ProductCode)" Name="InternalVersion" Value="$(var.ProductVersion)"/>
    </Component>
    <Directory Id="CommonAppDataFolder">
      <Directory Id="UninstallCompanyDir" Name="$(var.Manufacturer)">
        <Directory Id="UninstallProductDir" Name="$(var.ProductName)">
          <Component Id="UninstallerExe" Guid="*">
            <File Id="UninstallerExeFile" Name="Uninstaller.exe" Source="..\Uninstaller.exe" Vital="yes" KeyPath="yes">
            </File>
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </DirectoryRef>  

在Uninstaller.exe中,我将自身复制到TEMP文件夹并从那里运行,但问题是我的卸载程序在那里(在TEMP中)。

问题:如何使用wix脚本删除我的可执行文件(来自TEMP或原始文件)?

你可以批量做到这一点!

就像是

cmd.exe /C TIMEOUT 10 && del "{your uninstaller path}"

您在卸载程序关闭事件中运行它。 这将生成一个新的cmd进程,并在10秒后执行delete命令。

有一个文档的“如何”这个场景不需要你有一个可执行文件,使用msiexec.exe而不是你自己的可执行文件:

如何:创建卸载快捷方式

你没有说你的exe是否做了除了调用卸载之外的任何事情,但IMO完全可以复制到临时文件夹并将可执行文件保留在那里(并且它不需要是exe,因为你可以在其上调用CreateProcess作为.tmp文件)。 有一些标准工具可以清除临时文件夹(磁盘清理,服务器脚本),所以不用担心。

通常,从Windows 10开始,您不需要在开始菜单上卸载。 右键单击已安装的应用程序无论如何都会导致卸载,甚至可能会压制您的应用程序。

创建以下批处理文件。 这将运行卸载程序,当卸载程序完成后,它将删除卸载程序和批处理文件。

START /WAIT YourUninstaller.exe
Del YourUninstaller.exe
Del ThisBatchFile.bat

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM