Kallex
Posts: 25
Joined: Thu Aug 07, 2008 4:11 pm

Updater block until install complete

Hi!

I'd like to see a command line option added, that would allow updater to block until the update has installed (if it found any).

I might be missing something, but I see it bit tricky to implement simple automated script (for us its an independent self rebooted/restarted console app, that we want to silently update itself during the reboot cycle), as the application is launched on the next step before updater has completed.

Br,

Kalle
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Updater block until install complete

Hello,

This is already the normal behavior of the Auto Updater. I am not sure what you are trying to do. Can you please give me more details?

Thank you,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Kallex
Posts: 25
Joined: Thu Aug 07, 2008 4:11 pm

Re: Updater block until install complete

Hi!

I have following script (cmd file) that gets run on user login (that's autologin after reboot):

acupdate.exe /silentall -nofreqcheck
shutdown -r -f -t 900
bin\AutomationConsole.exe poll


Basically it starts to install, but also proceeds with the script so that the exe is running way before it even manages to uninstall/reinstall (major upgrade as we do); and the reboot timer is also ticking already.

We require it to pend for the duration of install as well, so that the exe launch will be with the new version.

We are running AI 7.1 now if it makes any difference; no reason for us not to upgrade to 7.1.3, just haven't done it just yet.


Br,

Kalle
Kallex
Posts: 25
Joined: Thu Aug 07, 2008 4:11 pm

Re: Updater block until install complete

Hi!

Also confirmed with 7.1.3... the updater pends until it is done downloading, but then when the actual installation starts, the updater exits.


Br,

Kalle
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Updater block until install complete

Hello,

The updater restarts itself after it has downloaded the update, which is why your .bat file proceeds to the next command. The correct way to wait for the updater to finish is to create your own executable that waits for the updater to finish, let's call it startupdate.exe, then organize your bat file like this:

Code: Select all

startupdate.exe
shutdown -r -f -t 900
bin\AutomationConsole.exe poll
Our guide on How to make an application wait for the Updater to finish explains the code for startupdate.exe
The reason the updater restarts itself is because the updater copies itself to a temporary location and runs from there, in case the update it just downloaded updates the updater itself.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Kallex
Posts: 25
Joined: Thu Aug 07, 2008 4:11 pm

Re: Updater block until install complete

Hi!

Few points that raise:

1. Shouldn't the startupdate.exe also call itself "away" so that it doesn't block the update?

2. The mutex call requires bit more explanation for my taste; does the updater reserve the mutex so that the startupdater.exe can handle it?

3. Why wouldn't you provide generic startupdate.exe that would allow the required input as command line parameters and/or .ini file?

Sounds a bit odd to require native C/C++ exe compilation or something alike based on the guidance (heck even .NET one) that would require to be in sync with your updater.


To me it sounds very common use-case where the critical or all updates are required before the actual deployed product application. It implies, that you currently seem to consider it a special case, hence the trickery to achieve it.

Or then I'm missing some easy-to-achieve use-case where updates are all applied before launching the actual product.


Br,

Kalle
Kallex
Posts: 25
Joined: Thu Aug 07, 2008 4:11 pm

Re: Updater block until install complete

Actually... simpler solution would allow updater not to exit after downloading.

The script could copy the updater and it's ini file to %TEMP% before starting, that would allow updater to update itself as well without having to restart (and cause the process to exit).

Initially that sounds like really small change, a command line option for updater.

Br,

Kalle
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Updater block until install complete

Hi,

Thank you for your suggestions. We will take them into consideration. Simply contact us by email on support at advancedinstaller dot com and we will send you a "wait for updater" sample project.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
Kallex
Posts: 25
Joined: Thu Aug 07, 2008 4:11 pm

Re: Updater block until install complete

Hello!

My contribution as a command line parametrizable C# implementation:

It is then launched within command set (copy is to prevent installation blocking as it updates the UpdaterStarter.exe as well).

copy bin\UpdaterStarter.exe .
UpdaterStarter.exe acupdate.exe "/silentall -nofreqcheck"
<and finally here (re)start the updated application>

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.IO;

namespace UpdaterStarter
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args) {
            if(args.Length != 2) {
                MessageBox.Show("Usage: UpdaterStarter <updater full path> <updater start args>");
                return;
            }
            string updaterExe = args[0];
            if(!File.Exists(updaterExe)) {
                MessageBox.Show("Updater does not exist: " + updaterExe);
                return;
            }
            updaterExe = Path.GetFullPath(updaterExe);
            string updaterParams = args[1].Replace("\"", "");
            Process updaterProc = Process.Start(updaterExe, updaterParams);
            updaterProc.WaitForExit();
            int exitCode = updaterProc.ExitCode;
            if(exitCode == 0) {
                string mutexName = updaterExe.Replace('\\', '_').Replace(".exe", ".mtx");
                waitForMutex(mutexName);
            }
        }

        private static void waitForMutex(string mutexName) {
            Mutex mutex = null;
            while(mutex == null) {
                try {
                    mutex = Mutex.OpenExisting(mutexName, MutexRights.Synchronize);
                } catch(WaitHandleCannotBeOpenedException) {
                    Thread.Sleep(500);
                }
            }
            try {
                mutex.WaitOne();
            } catch(AbandonedMutexException) {
                
            }
        }
    }
}

Enjoy!

Br,

Kalle

Return to “Feature Requests”