Stop the installation from a custom action

拈花ヽ惹草 提交于 2019-12-10 11:45:21

问题


Is it possible to exit msi installar from a custom action without errors?

I am using visual studio setup project to create the msi and I have added a custom action exe to install. If I return a value other than 0 from exe it terminate the installation. But it shows an error. I need to exit installation without showing errors.

Thanks.


回答1:


Finally I found a way to do it using a vbscript custom action from http://chensuping.blogspot.com/2013/05/windows-setup-project-vbs-custom-action.html.




回答2:


Try this code in your installer class. I hope it will resolve your problem.

protected override void OnBeforeInstall(IDictionary savedState)
        {
            if (LaunchOnBeforeInstall())
            {
                base.OnBeforeInstall(savedState);
            }
            else
            {
                throw new Exception("You cancelled installation");
            }
        }
        public bool LaunchOnBeforeInstall()
        {
            Form2 frm2 = new Form2();
            DialogResult result = frm2.ShowDialog();
            if (result == DialogResult.Cancel)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

And also put "NOTPREVIOUSVERSIONSINSTALLED"



来源:https://stackoverflow.com/questions/21753428/stop-the-installation-from-a-custom-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!