0

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

Nekeniehl
  • 1,633
  • 18
  • 35
  • What is your error ? Did you try to debug the installation process and commit function ? – Bioukh Feb 03 '15 at 11:48
  • I get the error at the end of the installation process, I don't really know how I can debug an msi =( The errors are differents depending on which solution I try, normally are the bad package error and contact with your deployer but there is no more especification than that – Nekeniehl Feb 03 '15 at 12:12
  • 1
    as i can see it here are to options: 1. The Update package will be compressed an contain 2 files: - MSI Package. - Small Application. the apllication will lunch the MSI and wait for it's end. When the MSI Finish the application will then start your software. 2. Send a Command argument to the MSI Package that set a lunch command to your application. – Tomer Klein Feb 03 '15 at 12:16
  • You can debug the installation process while starting it from Visual : right click on setup project, then "Install". – Bioukh Feb 03 '15 at 12:20
  • @Vincent, this doesn't let me debug it, it just trigger the installation, without let me put a breakpoint, I can attach to the process but is the same, without breakpoint just go forward. – Nekeniehl Feb 03 '15 at 12:56
  • Hi @TomerKlein, in your first approach I guess I have to use Process and ProcessInfo classes, it's a good idea though, but the second is more what I'm looking for, because the installation is silent so the user will not even notice there was an update, Do you have a starting point for this commands (msdn page or similar) – Nekeniehl Feb 03 '15 at 12:56
  • what are you using for your MSI Package Building? – Tomer Klein Feb 03 '15 at 12:57
  • The setup project addon from VS 2013, it's almost the same as the installation project of VS 2010, I can add custom actions, registry and so one – Nekeniehl Feb 03 '15 at 12:59
  • Try using installshield le it's free and you can set it to lunch application at the end...(it integrades with vs2013) – Tomer Klein Feb 03 '15 at 16:01

1 Answers1

1

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.

Bioukh
  • 1,888
  • 1
  • 16
  • 27
  • Hi, I just find the solution and it works, it makes almost the same as you, but with a little bit less code: http://stackoverflow.com/a/9024424/2315752 – Nekeniehl Feb 03 '15 at 15:10
  • 1
    OK, don't forget the try catch block. Exceptions while installing could lead to uninstall problem. – Bioukh Feb 03 '15 at 15:20