We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

bcnzer
Posts: 5
Joined: Thu May 01, 2014 12:32 am

Update app before application launches

What I'm trying to achieve is :
1) Having the updater check for updates, download them and install them BEFORE the application is run
2) Doing so with minimal user interaction. We want to force these updates onto the user
3) Avoid having the application forceably closed once the install starts. We don't want users to lose any work, etc. This point is quite important

I'm looking for suggestions on how to improve what I currently have or completely alternative solutions.

What I currently have is setup as a test is
1) Base installer for first time install (let's call it Version 4)
2) I've defined an update. In the Command Line, I entered /passive
3) Created a new version of my install package (let's call it Version 5)
4) In my application, the very first thing I do is run the updater with the command line of /silentall -nofreqcheck

So the result is:
* Initially install the app. Works fine
* Launch the app (version 4). I can see the icon in the system tray, as it downloads. Takes a while to download so there's a good possibility other users will start using our app
* When the download is complete, the install launches. The users gets the UAC message (undesirable - as it's possible the user will say No - but not a big deal). The installer then forceably closes the app
* Upon re-launching my app, I can see I'm upto Version 5

I'm aware I can add a custom action to detect or stop the process. Two problems I see are:
1) With the stop process, it forceably closes it. I'd rather we ask the user to shut it down before proceeding, similar to the MsiRMFilesInUse dialog. Is that possible?
2) Since I'm running with /passive, appears I can't ask the user anything before installing.

Any suggestions?
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Update app before application launches

Hello,

In order to achieve that you can use the predefined detect process custom action to detect if your process is running on the target machine. If the process is running, then you can prompt the user using the predefined Display message box custom action. Based on the user answer, you can abort the uninstall process or you can close the running process using the predefined terminate process custom action.

Please takea look on the How do I detect or stop a process? article with related information for hints and guidance. Also, you can take a look on our Checking for the running process and terminating the same forum thread which debates a similar subject.

Let me know if you have other questions.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bcnzer
Posts: 5
Joined: Thu May 01, 2014 12:32 am

Re: Update app before application launches

Thank you for that Dan but unfortunately the above doesn't help when I'm trying to install the updates with /passive.

I decided to adopt a slightly different tack. As per my objectives, I essentially wanted updates downloaded and installed forceably installed on users before they start my app. In other words: I wanted it to behave more like Clickonce.

The three main things I did were:
1) Wrote a small application that either downloads updates (if they exist) or just launches my app (does more than this - I'll explain in a moment).
2) Changed the shortcuts to my main EXE so it instead points to the above. I also set the shortcut to be that of my main app.
3) Wrote a custom action that would launch my main EXE only if it's being run silently. Reason for this is that, if the user clicked the app icon it would download then install the app and, once done, would expect to be able to use the latest version (like Clickonce)

The small application does a few things:
* The UI is very simple. Just an animated wait icon (similar to that in Windows 8) and text status i.e. checking for updates, downloading, error, etc.
* Reads in an INI generated by AI. The INI explictly tells me two things: (1) full path to the updater EXE and (2) full path to the main EXE. Note that I couldn't use command line params in the shortcut as those two are long. It's like they got truncated. Also, I could have hard-coded or made assumptions about the above (thereby avoiding the need for an INI) but I plan on reusing this appfor another one of our products.
* In code, created a separate thread to check for an update using /justcheck and looking at the return code.
* If there is no update, this app is closed and my main app is launched.
* If there is an update I start downloading it and update the status text. I pass the updater the command line of /silentall -nofreqcheck.
* At this point I want to wait for the download to finish. For some reason the usually "launch and wait" functionality didn't work so I created a timer that would periodically checked to see if the updater process was still running. Once it was no longer running I closed this app.
* Once the update is downloaded, it installs using the /passive command line (this is defined in the update txt file on my server). At the end it launches the new version of my application.

Another neat thing I've done (which may be obvious to many people out there) is use Azure blobs to store my installs and updates. My infrastructure team were sick of hosting our Clickonce on our web servers. We can do a lot of updates so they could take up a lot of disk space and bandwidth. Azure blobs is very cheap and is effectively unlimited disk space. I imagine you could do the same with Amazon, etc.

Any file you upload there has a distinct URL i.e. http://myinstalls.blob.core.windows.net/installs/myapp 1.0.0.exe. To upload files I use a have tool (i.e. Cloudberry Explorer). Would be nice if AI could do talk directly to Azure via a post-build action, so that it this automated (would mean I would have to provide my Azure blob details somewhere in settings). I think I'll work around this by getting either figuring out how to pass command lines to up my current tool or using a different app that can map a drive to my Azure blob account. But either way it means having an extra piece of software on my PC.

Anyway, I hope the above helps someone.

Return to “Building Installers”