我有我的自定义安装程序和卸载程序,其中安装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中)。
问题:如何使用脚本删除可执行文件(从临时文件或原始文件中删除)?
发布于 2018-05-02 14:52:32
你可以用批处理完成这件事!
就像这样
cmd.exe /C TIMEOUT 10 && del "{your uninstaller path}"在卸载程序关闭事件中运行它。这将产生一个新的cmd进程,并在10秒后执行删除命令。
发布于 2018-05-02 17:48:07
对于这个场景,有一个记录在案的“如何”,它不要求您有一个可执行文件,而是使用msiexec.exe而不是您自己的可执行文件:
如何:创建卸载快捷方式
您不会说您的exe除了调用卸载之外是否执行其他任何操作,但是,将其复制到临时文件夹并将可执行文件留在那里是完全可以接受的(而且它不需要是exe,因为您可以将它上的CreateProcess作为.tmp文件调用)。有一些标准的工具可以清除临时文件夹(磁盘清理,服务器脚本),所以不要担心。
通常,您不需要从Windows 10开始在“开始”菜单上卸载。右键单击已安装的应用程序,无论如何都会弹出卸载,甚至可能会抑制您的卸载。
发布于 2018-05-02 17:22:45
创建以下批处理文件。这将运行卸载程序,当卸载程序完成时,它将同时删除卸载程序和批处理文件。
START /WAIT YourUninstaller.exe
Del YourUninstaller.exe
Del ThisBatchFile.bathttps://stackoverflow.com/questions/50137373
复制相似问题