简体   繁体   中英

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.

I find some topics about it but nothing seems to works because different errors (bad package, error 1001, etc).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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