简体   繁体   English

安装后启动

[英]Launch after installation

I have an auto update application, when there is new updates, I download via ftp the installer.msi, I silent installed it and close the application, what I'm wondering is how to restart the application after the installation was successful. 我有一个自动更新的应用程序,当有新的更新时,我通过ftp下载installer.msi,我无声安装并关闭了该应用程序,我想知道如何在安装成功后重新启动该应用程序。

I find some topics about it but nothing seems to works because different errors (bad package, error 1001, etc). 我找到了一些有关它的主题,但是似乎没有任何用处,因为有不同的错误(错误的软件包,错误1001等)。

I think the approach where you add the output on the commit of the installer is the good one but I can not make it work, Any Ideas? 我认为在安装程序的提交上添加输出的方法是一种不错的方法,但我无法使其正常工作,有什么想法吗?

Thanks in advance 提前致谢

This works for me : 这对我有用:

[RunInstaller(true)]
public partial class Installer1 : Installer
{
    public Installer1()
    {
        InitializeComponent();
    }

    public override void Install(IDictionary savedState)
    {
        savedState.Add("InstallDir", Context.Parameters["dir"]);
        base.Install(savedState);
    }

    public override void Commit(IDictionary savedState)
    {
        base.Commit(savedState);
        Start(savedState);
    }

    private void Start(IDictionary savedState)
    {
        try
        {
            string DirPath = (string)savedState["InstallDir"];
            if (!string.IsNullOrEmpty(DirPath))
            {
                Process.Start(DirPath + @"\WindowsFormsApplication1.exe");
            }
        }
        catch
        {
        }
    }
}

You have to define /dir="[TARGETDIR]\\" for CustomActionData of Install action. 您必须为Install操作的CustomActionData定义/dir="[TARGETDIR]\\"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM