Using AutomaticUpdater with Custom UI

I'm in the process of adding updating support to my DirectX application using AutomaticUpdater.

If an update has been found and the user has indicated that they want to update now (via my own custom UI), it's unclear to me what I need to do in order to close my app, start the updater, and then restart the app.

Do I only need to call AutomaticUpdater.InstallNow() ?

If so, what does this function doing behind the scene?

I'm in the process of adding updating support to my DirectX application using AutomaticUpdater.

If an update has been found and the user has indicated that they want to update now (via my own custom UI), it's unclear to me what I need to do in order to close my app, start the updater, and then restart the app.

Do I only need to call AutomaticUpdater.InstallNow() ?

Yes. That's right. If you were using the built-in UI (namely, the menu integration), by clicking the menu the following code would be executed:

            switch (automaticUpdater.UpdateStepOn)            {                case UpdateStepOn.Checking:                case UpdateStepOn.DownloadingUpdate:                case UpdateStepOn.ExtractingUpdate:


                    automaticUpdater.Cancel();                    break;


                case UpdateStepOn.UpdateReadyToInstall:                case UpdateStepOn.UpdateAvailable:                case UpdateStepOn.UpdateDownloaded:


                    automaticUpdater.InstallNow();                    break;


                default:


                    automaticUpdater.ForceCheckForUpdate();                    break;            }

It's all done behind the scenes, but that's what's being executed.

If so, what does this function doing behind the scene?

The AutomaticUpdater tells wyUpdate that your app is about to close. wyUpdate acknowledges this waits for your app to close. (Waiting for your user to save their files, etc.).

The AutomaticUpdater then tries to close your app. Once your app is closed, wyUpdate shows itself & finishes the update process. Then it relaunches your app.

That helps. Thank you.

Two more questions:

To be clear, you can call automaticUpdater.InstallNow() even thought the update hasn't been downloaded yet, correct?

If an update is found... How can I start downloading it in the background before calling InstallNow?

Correct, just call InstallNow() to download the file.

I am really struggling to make this work. I'm very frustrated.I'm obviously trying to use AutomaticUpdater in a way that it wasn't designed for.

When I call InstallNow() it will sometimes close the app but then doesn't run wyUpdate.exe or ever relaunch my program.

What I want to happen if an update is found is to close my program right away (which it doesn't do because I think it's background downloading the update), launch wyUpdate and download the update without the user have to click anything, then when the update is installed, relaunch my app (again with out any confirmation or clicking).

At this point I think that manually launching wyUpdate.exe might be easier. I'd love a command on wyUpdate.exe that performed an update (without any user intervention) and relaunched whatever exe was passed to it. Do those command line parameters exist?

Also, where does wyUpdate.exe store its info? I'd like to clear out the cache as I wonder if this is causing a problem in testing the update feature.

wyUpdate.exe also seems to be making some kind of system beep sound when it finds an update (when called by the AutomaticUpdater control). Is there a way to disable the sound?

I'm really excited to get this working as I really love the wyBuild tool and how easy it is to use.

, edited
When I call InstallNow() it will sometimes close the app but then doesn't run wyUpdate.exe or ever relaunch my program.

Let me ask you this: is wyUpdate.exe running (in the taskmanager) when you call InstallNow() and it fails?

What I want to happen if an update is found is to close my program right away (which it doesn't do because I think it's background downloading the update), launch wyUpdate and download the update without the user have to click anything, then when the update is installed, relaunch my app (again with out any confirmation or clicking).

At this point I think that manually launching wyUpdate.exe might be easier. I'd love a command on wyUpdate.exe that performed an update (without any user intervention) and relaunched whatever exe was passed to it. Do those command line parameters exist?

No. Unfortunately the automated installing is more than just a few command line switches.

Also, where does wyUpdate.exe store its info? I'd like to clear out the cache as I wonder if this is causing a problem in testing the update feature.

2 places:

C:\Users\YOURUSERNAME\wc\and%appdata%\wyUpdate AU\

Just type them into the run box in the start menu.

I am really struggling to make this work. I'm very frustrated.I'm obviously trying to use Automatic Updater in a way that it wasn't designed for.

If you show me some of your code I might be able to help you out. (Send it to wyatt@wyday.com).

Ok, I've been thinking about it for a bit, and it just occurred to me: before you check for updates first set the "UpdateType" property to "Automatic".

This will ensure the update goes from being checked, download, extracted, and installed all without your intervention.

Then when the "ReadyToBeInstalled" event is called, simply call InstallNow().

This will close the app, finish the installation, and restart your app.

Then, when either the "UpdateFailed" or "UpdateSuccessful" events are called, you can set the "UpdateType" back to "DoNothing" if you don't want the AutomaticUpdater taking care of all the details for you.

Wow... Thanks so much. That was very helpful. It's still not working correctly, but it's working 'better'.

Here's what I did to test the update feature...

Created v1I published from Visual Studio a v1 of my program.I added these files to the v1 tab in wyBuild.I created a wyUpdate for inclusion.I added these two files to the published folder.I created a file list and made a setup.exe file

Created v2I then published from Visual Studio a v2 of my program.I added these files to a new v2 tab in wyBuild.I created a wyUpdate for inclusion.I added these two files to the published folder.I created a Build Update and uploaded these 3 files to my web server.

Cleaned up FilesI cleaned up everything from previous installations and testing.I uninstalled my program and deleted both of these folders:- C:\Documents and Settings\YOURUSERNAME\wc\- %appdata%\wyUpdate AU\(I'm running XP)

I now ran the setup.exe file of v1 to install the program.And clicked on a button in my program that forces a check for update.

This creates a form (UpdateForm) that only has the AutomaticUpdater control on it.

UpdateBox = New UpdateFormUpdateBox.ShowInTaskbar = FalseUpdateBox.WindowState = FormWindowState.MinimizedUpdateBox.Show()UpdateBox.Hide()AU = UpdateBox.AutomaticUpdater1AU.KeepHidden = FalseAU.DaysBetweenChecks = 1AU.wyUpdateLocation = "wyUpdate.exe"AU.UpdateType = wyDay.Controls.UpdateType.AutomaticAU.WaitBeforeCheckSecs = 5AU.Name = "AutomaticUpdater"AU.wyUpdateCommandline = Nothing

(where AU is defined as: Friend WithEvents AU As wyDay.Controls.AutomaticUpdater)

and then it calls the check for update command:

AU.ForceCheckForUpdate()

So far everything is working and it finds the update and continuously triggers the processed changed event and downloads the smaller patch from my website. Awesome.

Private Sub AU_ProgressChanged(ByVal sender As Object, ByVal progress As Integer) Handles AU.ProgressChanged

After the download is complete this gets called:

Private Sub AU_ReadyToBeInstalled(ByVal sender As Object, ByVal e As System.EventArgs) Handles AU.ReadyToBeInstalled

Where I set a flag that elsewhere in my program indicates that we need to show a dialog box asking if they want to update when it's an appropriate time to exit the program.

Once this dialog is displayed and the user selects "Update" I call this:

AU.InstallNow()

I also set an UpdateSystem.Shutdown flag that I use to force the main form closed:

    Private Sub MainForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing


        If UpdateSystem.Shutdown = False Then            If Engine.Shutdown = False Then                e.Cancel = True                Engine.ShutdownRequested = True            End If        End If    End Sub


Since shutdown is true, the e.Cancel remains false and the program closes.

Here's where the problem occurs...

wyUpdate.exe is still running (as confirmed by the Task Manager) and it seems to hang.

wyUpdate.exe never finishes or closes and the program is never restarted.

Interestingly if I manually close wyUpdate.exe and run my program again the Update Check will fail. Running it a 3rd time and the update is detected (as already being downloaded) and I'm asked if I want to update. Which closes the program and results in wyUpdate.exe hanging. If I run it again the update check will fail and the cycle repeats itself.

I'm also seeing that if I choose not to call AU.InstallNow (because of the AU.ReadyToBeInstalled being called) that the event AU.ReadyToBeInstalled is called again almost instantly.

Then, when either the "UpdateFailed" or "UpdateSuccessful" events are called, you can set the "UpdateType" back to "DoNothing" if you don't want the AutomaticUpdater taking care of all the details for you.

[/quote]

I'm checking for these, but don't see that these have ever been called in all of my testing.

Let me know if there's anything else I can provide that would be of help.

Thanks again for your help. It's going to be awesome when it works.

Where I set a flag that elsewhere in my program indicates that we need to show a dialog box asking if they want to update when it's an appropriate time to exit the program.

Once this dialog is displayed and the user selects "Update" I call this:

AU.InstallNow()

I also set an UpdateSystem.Shutdown flag that I use to force the main form closed:

    Private Sub MainForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing


        If UpdateSystem.Shutdown = False Then            If Engine.Shutdown = False Then                e.Cancel = True                Engine.ShutdownRequested = True            End If        End If    End Sub


Since shutdown is true, the e.Cancel remains false and the program closes.

Here's where the problem occurs...

wyUpdate.exe is still running (as confirmed by the Task Manager) and it seems to hang.

wyUpdate.exe never finishes or closes and the program is never restarted.

Is the wyUpdate.exe version 2.5.13? (Right click, click properties).

Are you adding the AutomaticUpdater control to the form. That is, is the control visible on form in the designer window? Or are you creating it in code (e.g. AU = new AutomaticUpdater() )?

Because if you're using the latest wyUpdate, and you're adding the AutomaticUpdater directly to the main form, everything should work fine.

In fact, using the method you described, except just using AU.InstallNow() in the ReadyToBeInstalled event everything works.

Let me ask you this, if you use the method as described on the video tutorial to the AutomaticUpdater, does everything work perfectly?

Then, when either the "UpdateFailed" or "UpdateSuccessful" events are called, you can set the "UpdateType" back to "DoNothing" if you don't want the AutomaticUpdater taking care of all the details for you.

I'm checking for these, but don't see that these have ever been called in all of my testing.

Let me know if there's anything else I can provide that would be of help.

Thanks again for your help. It's going to be awesome when it works.

UpdateFailed & UpdateSuccessful are called after your app restarts (i.e. it's run on your new version).

I got working and it's awesome!

Thanks so much for your help. It was invaluable.

I'll report back in a few days with the details.

Thanks again for all of your help and fast responses Wyatt.

I was doing it this way:

I was starting up on Main() and then creating an invisible form with the Automatic Updater control on it. This worked for getting and downloading updates, but was problematic when it tried to close and restart my app.

Here's what I did in order to make it work:

I created a new "startup" form and added the Automatic Updater control to it. I changed my app to startup on this form and then launch the original "main" form of my app. Once the Automatic Updater indicated that it was ready to install the update I performed my standard exit procedure, closing the "main" form, and then called the InstallNow() when there was nothing to get in the way of a proper exit.

My main problem was that my original code wasn't allowing for a "proper" application exit.

While I've got it working pretty well now... I wish there was a way to call some like "Download Only", separate from an "Install Now and Exit" call.

One other problem I had was that in my haste to release an update I accidentally added wyUpdate.exe to the list in wyBuild which cased an error when my app tried to update. Also, until I ran wyUpdate separately there was no apparent way to see the error that I was getting during the automatic update. I'd suggest adding some kind of warning message into wyBuild when it thinks you've added wyUpdate to the list.

Thanks again. I'm very satisfied with your product.

Thanks again for all of your help and fast responses Wyatt.

I was doing it this way:

I was starting up on Main() and then creating an invisible form with the Automatic Updater control on it. This worked for getting and downloading updates, but was problematic when it tried to close and restart my app.

Here's what I did in order to make it work:

I created a new "startup" form and added the Automatic Updater control to it. I changed my app to startup on this form and then launch the original "main" form of my app. Once the Automatic Updater indicated that it was ready to install the update I performed my standard exit procedure, closing the "main" form, and then called the InstallNow() when there was nothing to get in the way of a proper exit.

My main problem was that my original code wasn't allowing for a "proper" application exit.

We've found that this is a problem with some people. Especially those employing splash screens. We're thinking about a sane solution to this problem. (It's a tough one).

While I've got it working pretty well now... I wish there was a way to call some like "Download Only", separate from an "Install Now and Exit" call.

Well, if the AutomaticUpdater.UpdateStepOn == UpdateStepOn.UpdateAvailable then calling InstallNow() will download the update. The trouble with making separate functions for all the different steps (check, download, extract, install, etc.) is that they might be called out of order (downloading before any new update has been checked for - or downloading after the update has already been downloaded, etc.)

The problem becomes, what do we do when this happens? Throw an exception? Silently ignore out-of-order requests?

It gets tricky real fast.

We will be writing some help articles about using the functions to build a custom UI. To clarify some of the problems that came up in this topic.

One other problem I had was that in my haste to release an update I accidentally added wyUpdate.exe to the list in wyBuild which cased an error when my app tried to update. Also, until I ran wyUpdate separately there was no apparent way to see the error that I was getting during the automatic update. I'd suggest adding some kind of warning message into wyBuild when it thinks you've added wyUpdate to the list.

That's a good idea. We'll add it to wyBuild 2.6.

Thanks again. I'm very satisfied with your product.

Thanks, I'm glad to help.