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