简体   繁体   English

wix uninstaller(exe)如何自行删除

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

I have mine custom installer and uninstaller, which install MSI and other resources to PC. 我有自定义安装程序和卸载程序,它将MSI和其他资源安装到PC。 Uninstall process works within the lines below: 卸载过程在以下行中有效:

<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>  

In Uninstaller.exe i copy itself to TEMP folder and run it from there, but problem is my uninstaller left there (in TEMP). 在Uninstaller.exe中,我将自身复制到TEMP文件夹并从那里运行,但问题是我的卸载程序在那里(在TEMP中)。

Question: How I can remove my executable file(from TEMP or original) with wix scripts ? 问题:如何使用wix脚本删除我的可执行文件(来自TEMP或原始文件)?

You can do this with batch! 你可以批量做到这一点!

something like 就像是

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

You run it at the uninstaller closing event. 您在卸载程序关闭事件中运行它。 This will spawn a new cmd process and execute the delete command after 10seconds. 这将生成一个新的cmd进程,并在10秒后执行delete命令。

There is a documented "how to" for this scenario that doesn't require you to have an executable, using msiexec.exe instead of you own executable: 有一个文档的“如何”这个场景不需要你有一个可执行文件,使用msiexec.exe而不是你自己的可执行文件:

How To: Create an Uninstall Shortcut 如何:创建卸载快捷方式

You don't say whether your exe does anything other than call the uninstall, but IMO it's perfectly acceptable to copy to a temp folder and leave the executable there (and it doesn't need to be an exe because you can call CreateProcess on it as a .tmp file). 你没有说你的exe是否做了除了调用卸载之外的任何事情,但IMO完全可以复制到临时文件夹并将可执行文件保留在那里(并且它不需要是exe,因为你可以在其上调用CreateProcess作为.tmp文件)。 There are standard tools that clear out temp folders (Disk Cleanup, server scripts) so don't worry about it. 有一些标准工具可以清除临时文件夹(磁盘清理,服务器脚本),所以不用担心。

In general you don't need an uninstall on the start menu from Windows 10 onwards. 通常,从Windows 10开始,您不需要在开始菜单上卸载。 A right-click on an installed app brings up an uninstall anyway, and it may even suppress yours. 右键单击已安装的应用程序无论如何都会导致卸载,甚至可能会压制您的应用程序。

Create following batch file. 创建以下批处理文件。 This will run uninstaller, when uninstaller is done, it will delete uninstaller and batch file both. 这将运行卸载程序,当卸载程序完成后,它将删除卸载程序和批处理文件。

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

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

相关问题 使用 Wix 3.8,当卸载程序打包在 exe 安装程序中时,如何使用 Bundle 卸载 ExePackage? - Using Wix 3.8, using Bundle how do Uninstall an ExePackage when the uninstaller is packaged up inside an exe installer? NSIS卸载程序删除保存文件 - NSIS Uninstaller to remove save files 事件处理程序委托可以将自身删除吗 - Can a eventhandler delegate remove itself Wix - 从安装目录安装后如何运行 exe 文件? - Wix - How to run exe files after installation from installed directory? 如何将[ConsoleAppName] .exe.config包含到wix安装中 - How to include [ConsoleAppName].exe.config to wix installation 如何避免安装相同的应用程序实例 wix 安装程序 MSI 和 EXE? - How to avoid install same instance of application wix installer MSI & EXE? 如何在Visual Studio 2008中调试安装程序项目的卸载程序部分(使用CustomAction) - How can I debug the uninstaller part (with CustomAction) of an installer project in Visual Studio 2008 Visual Studio安装项目:如何强制卸载程序以管理员模式运行? - Visual Studio Setup Project: How Can I force an Uninstaller to run in Administrator mode? Wix Change exe安装程序图标 - Wix change exe installer icon 如何使用自定义卸载程序卸载Windows服务 - How to uninstall Windows service using Custom Uninstaller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM