从我的自定义操作取消安装
我正在使用 Windows Installer(而不是 wix)为我的程序编写安装程序。 在某些情况下,我想从自定义操作中取消安装过程。此外,我想在我的文本中显示一条错误消息。 这怎么办?
C#、.net 3.5
I'm writing installer for my program using Windows Installer (not wix).
In some cases i want cancel installation proccess from my custom action. Beside, i want show an error message with my text.
How do this?
C#, .net 3.5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以通过创建错误自定义操作来执行此操作。将错误自定义操作的条件设置为失败条件(如果条件评估为 true,则安装将失败)并将消息设置为您的自定义文本。
You can do this by creating an error custom action. Set the condition of the error custom action to be the fail condition (if the condition evaluates to true, the installation will fail) and set the message to your custom text.
对我来说工作:
上下文:出于某种原因,我需要检查用户是否安装了 3.5SP1,如果没有,则取消安装并重定向到正确的下载页面。
步骤一:
像这样修改你的安装程序
第2步:
使用该代码托管您的 MessageBox(我把它带到其他地方,没有时间自己找到它)
第 3 步:
杀死 msiexec
用勺子而不是摇酒器将其混合并食用;)
Working thing for me:
Context: for some reason I need to check if the user has 3.5SP1 installed, cancel the install and redirect to the correct download page if not.
Step1:
Modify your installer like this
Step2:
Use that code to host your MessageBox (I took it elsewhere, no time to find it by myself)
Step3:
Kill the msiexec
Mix it with a spoon not with a shaker and serve ;)
只需从自定义操作中返回 ERROR_INSTALL_USEREXIT 即可。
http://msdn.microsoft。 com/en-us/library/windows/desktop/aa368072(v=vs.85).aspx
请参阅以下链接了解如何显示错误消息:
http://msdn.microsoft.com/en-us/library/windows/desktop /aa371247(v=vs.85).aspx
Just return ERROR_INSTALL_USEREXIT from your custom action.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa368072(v=vs.85).aspx
Please see the following link on how to display an error message:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa371247(v=vs.85).aspx
在任何时候,您认为需要中止:
安装程序将弹出“用户中止”对话框,其中包含异常消息。
At any point you consider you need to abort just:
The installer will popup the User Aborted dialog with your Exception message.