在使用 WiX 卸载应用程序之前,批处理文件未执行 [英] Batch file is not executing before application uninstalled using WiX
问题描述
我在需要卸载 Excel 插件时尝试运行的批处理文件未执行.我正在使用以下自定义操作来执行安装后以及卸载产品.以下代码:
My batch file that I'm trying to run when an Excel plugin needs to be uninstalled is not executing. I'm using the following custom actions to do post install and also on uninstalling the product. The following code:
<CustomAction Id="registeraddin" ExeCommand="[INSTALLFOLDER]RegisterMilerAddIn.bat" Directory="INSTALLFOLDER" Impersonate="no" Execute="deferred" Return="asyncWait" />
<CustomAction Id="unregisteraddinpostinstall" ExeCommand="[INSTALLFOLDER]UnRegisterMilerAddIn.bat" Directory="INSTALLFOLDER" Impersonate="no" Execute="deferred" Return="asyncWait" />
<InstallExecuteSequence>
<Custom Action="registeraddin" After="InstallFiles">NOT Installed</Custom>
<Custom Action="unregisteraddinpostinstall" After="InstallFiles">Installed AND (REMOVE = "ALL")</Custom>
</InstallExecuteSequence>
在日志中产生这个错误:
Produces this error in the log:
MSI (s) (44:04) [11:29:00:437]:执行操作:ActionStart(Name=unregisteraddinpostinstall,,)
MSI (s) (44:04) [11:29:00:437]: Executing op: ActionStart(Name=unregisteraddinpostinstall,,)
MSI (s) (44:04) [11:29:00:437]:执行操作:CustomActionSchedule(Action=unregisteraddinpostinstall,ActionType=1058,Source=C:Program文件 (x86)Werner EnterprisesWeb Miles ExcelAddin,Target=C:Program Files (x86)Werner EnterprisesWeb MilesExcel AddinUnRegisterMilerAddIn.bat,)
MSI (s) (44:04) [11:29:00:437]: Executing op: CustomActionSchedule(Action=unregisteraddinpostinstall,ActionType=1058,Source=C:Program Files (x86)Werner EnterprisesWeb Miles Excel Addin,Target=C:Program Files (x86)Werner EnterprisesWeb Miles Excel AddinUnRegisterMilerAddIn.bat,)
MSI (s) (44:04) [11:29:00:846]: 注意: 1: 1722 2:unregisteraddinpostinstall 3: C:Program Files (x86)WernerEnterprisesWeb Miles Excel Addin 4: C:Program Files (x86)WernerEnterprisesWeb Miles Excel AddinUnRegisterMilerAddIn.bat
MSI (s) (44:04) [11:29:00:846]: Note: 1: 1722 2: unregisteraddinpostinstall 3: C:Program Files (x86)Werner EnterprisesWeb Miles Excel Addin 4: C:Program Files (x86)Werner EnterprisesWeb Miles Excel AddinUnRegisterMilerAddIn.bat
MSI (s) (44:04) [11:29:00:846]: 注意: 1: 2205 2: 3: 错误 MSI (s)(44:04) [11:29:00:846]: 注意: 1: 2228 2: 3: 错误 4: SELECT Message
FROM Error
WHERE Error
= 1722 CustomActionunregisteraddinpostinstall 返回了实际的错误代码 100(注意这个如果翻译发生在沙箱内,可能不会 100% 准确)
MSI (s) (44:04) [11:29:00:846]: Note: 1: 2205 2: 3: Error MSI (s)
(44:04) [11:29:00:846]: Note: 1: 2228 2: 3: Error 4: SELECT Message
FROM Error
WHERE Error
= 1722 CustomAction
unregisteraddinpostinstall returned actual error code 100 (note this
may not be 100% accurate if translation happened inside sandbox)
MSI (s) (44:04) [11:29:10:900]: 注意: 1: 2205 2: 3: 错误 MSI (s)(44:04) [11:29:10:900]: 注意: 1: 2228 2: 3: 错误 4: SELECT Message
FROM 错误
WHERE 错误
= 1709
MSI (s) (44:04) [11:29:10:900]: Note: 1: 2205 2: 3: Error MSI (s)
(44:04) [11:29:10:900]: Note: 1: 2228 2: 3: Error 4: SELECT Message
FROM Error
WHERE Error
= 1709
MSI (s) (44:04) [11:29:10:900]:产品:WebMiles_Addin_Installer --错误 1722.此 Windows 安装程序包有问题.一个作为设置的一部分运行的程序未按预期完成.接触您的支持人员或软件包供应商.行动unregisteraddinpostinstall,位置:C:Program Files (x86)WernerEnterprisesWeb Miles Excel Addin,命令:C:Program Files(x86)Werner EnterprisesWeb Miles ExcelAddinUnRegisterMilerAddIn.bat
MSI (s) (44:04) [11:29:10:900]: Product: WebMiles_Addin_Installer -- Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action unregisteraddinpostinstall, location: C:Program Files (x86)Werner EnterprisesWeb Miles Excel Addin, command: C:Program Files (x86)Werner EnterprisesWeb Miles Excel AddinUnRegisterMilerAddIn.bat
这个错误对我来说是模糊的.我也没有在我的批处理文件中做真正花哨的东西.Excel 插件的安装工作正常(这是此应用程序的前提).但显然,我无法以同样的方式卸载插件,因此日志中出现上述错误.
That error is obscure to me. I'm not doing real fancy stuff in my batch file either. The installation of the Excel addin works fine (which is the premise of this application). But I can't uninstall the addin, apparently, in the same manner, so goes the aforementioned error in the log.
为了完整起见,这是我的注册批次的内容(RegisterMilerAddIn.bat):
For completeness, this is the contents of of my register batch (RegisterMilerAddIn.bat):
SET WorkFolder= "C:Program Files (x86)Werner EnterprisesWeb Miles Excel Addin"
SET _NET_4_Folder= %WinDir%"Microsoft.NETFrameworkv4.0.30319"
%_NET_4_Folder%
egasm.exe %WorkFolder%Miler.ExcelAddin.dll /Codebase /tlb:%WorkFolder%Miler.ExcelAddin.tlb >> C: emplog.txt
并取消注册批次(UnRegisterMilerAddIn.bat):
SET WorkFolder= "C:Program Files (x86)Werner EnterprisesWeb Miles Excel Addin"
SET _NET_4_Folder= %WinDir%"Microsoft.NETFrameworkv4.0.30319"
%_NET_4_Folder%
egasm.exe /unregister %WorkFolder%Miler.ExcelAddin.dll /Codebase /tlb:%WorkFolder%Miler.ExcelAddin.tlb >> C: emplog.txt
推荐答案
在研究和尝试了许多不同的属性之后,我找到了解决问题的方法.所以我把它贴在这里可能对其他人有帮助.我发现我的批处理文件在我运行插件卸载过程之前就被删除了,正如 Brian Sutherland 所逃避的那样.我终于发现在删除所有文件之前的卸载中一次执行了以下代码.
After researching and trying many different atrributes, I found a solution to my problem. So I'm posting it here may it help someone else. I was finding that my batch file was being deleted before I could run the addin uninstall process, as Brian Sutherland eluded to. I finally found the following code executed at a time in the uninstall that was before the removal of all the files.
<InstallExecuteSequence>
<Custom Action="unregisteraddinpostinstall" After="InstallInitialize">REMOVE="ALL"</Custom>
</InstallExecuteSequence>
所以我仍将使用上述代码,但我将实施 Stein Asmul 的建议来清理我的进程,而不是使用批处理文件.我仍在使用 After="InstallInitialize"
的原因是我的 ExcelAddin.dll 也是删除类型类库的 regasm.exe/unregister
进程的一部分.在我运行脚本之前它也被删除了.在我实施 After="InstallInitialize">REMOVE="ALL" 后,脚本按预期工作.再次感谢 Brian 和 Stein!
So I will still be using the above code, but I am going to implement Stein Asmul's suggestions to clean up my process and not use a batch file. The reason I am still using After="InstallInitialize"
is my ExcelAddin.dll is also part of the regasm.exe /unregister
process to remove Type Class Libraries. It too was being deleted before I could run the script. After I implemented After="InstallInitialize">REMOVE="ALL", the script is working as expected. Thanks again to Brian and Stein!
这篇关于在使用 WiX 卸载应用程序之前,批处理文件未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!