Trouble keeping my app from starting when there's an update

Maybe I'm missing something really simple here.

In my program.cs file I launch the wyUpdate.exe with the -quickcheck argument with a call the Process.Start

If there is an update available, I'd like to avoid the Application.Run call that launches my app so that the updater won't need to prompt me to close the app it's trying to update.If no update or an update error, then continue on and launch the app as normal.

How can I guard here? Checking the exit code doesn't seem to work, since it returns 0 if there is an update and 0 if there isn't. Looking at the source, I can see that the exit code is only set to 1 when there is an error (and you've got some comments in there about putting in real error codes, so I understand this isn't fully fleshed out yet).

Or maybe there is a different method?

As a side note, it would be really handy if the automaticupdater control's functionality was exposed in a non GUI component or a simple class, something that didn't need a CreateControl/CreateHandle call, though I think I saw some comments about this being necessary for some reason. If there was a way to do this, it would make the updater much more flexible.

Thanks for any help,-Erik

Hi Erik,

How can I guard here? Checking the exit code doesn't seem to work, since it returns 0 if there is an update and 0 if there isn't. Looking at the source, I can see that the exit code is only set to 1 when there is an error (and you've got some comments in there about putting in real error codes, so I understand this isn't fully fleshed out yet).

wyUpdate returns 0 if there wasn't an update, and it doesn't return at all if there is an update. (That is, it just shows itself to the user). You could detect when the wyUpdate window is visible (a quick & dirty method would to loop for about a second or 2, polling the wyUpdate process to see if the window is visible, then exiting your app if wyUpdate is visible).

Or

We could add another commandline switch to wyUpdate:

wyUpdate.exe -quickcheck -justcheck

Where wyUpdate would return 2 if there's an update available and return 0 if there's no update available. This would allow you to re-run wyUpdate.exe again & exit your app if there's an update available.

Would this work for you?

Or maybe there is a different method?

Unfortunately the only other way to do silent updates is to use the AutomaticUpdater control. And it currently doesn't work with apps without a GUI.

I actually tried this myself, I recompiled the wyupdate from the source and replaced the no update error code with -1. However, when I compiled and ran, it was no longer able to read my client.wyc files. I'm not sure what I goofed up, but it don't work no more.

if you could change that exit code, that would be awesome!

I understand that it is supposed to just show itself when an update is available. I have a process.waitforexit call there to make sure it's done before moving on. When the update is available, I click through and I'm guessing wyupdate closes itself and relaunches or something, because the process exits, the exit code is 0 and my app launches. I've walked through the debugger and it's pretty simple to verify. My app launches as wyUpdate is trying to perform the update and the close process dialog box pops up.

This might be even more prevalent if the updater has to update itself first, in which case it would definitely have to relaunch itself. The exit code in that case is also 0 currently.

Here's my code (from my modified wyUpdate that returns -1 for no update):

Process p = Process.Start(Application.StartupPath + "\\wyupdate.exe", "-quickcheck"); p.WaitForExit(); if (p.ExitCode !=0 ) //No updates or update error { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);

// begin displaying the splash screen before running the application form SplashScreen.SetBackgroundImage(EnergyPro.Properties.Resources.banner); SplashScreen.SetTitleString("Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString()); SplashScreen.BeginDisplay();

Application.Run(new MainForm(args)); }

What's the code formatting tag anyway?

Another side note:

Also would be cool if wyBuild could brand the wyUpdate.exe with product/company name.

Why aren't you using the AutomaticUpdater control? If you're using Windows Forms (which, from the sample you posted it looks like you are), then just adding the AutomaticUpdater control to your main form will handle all of the updating logic for you.

You can even customize the appearance of the control if it doesn't fit your needs.

Also, if you don't want to add full automatic updating ability to your app then you can just use the UpdateType property and set it to CheckOnly.

What's the code formatting tag anyway?

We use phpBB and it has a terrible spam problem. We had to disable all tags to stop spammers from posting crap. So unfortunately no tags are supported.

The reason I'm not using the automatic updater control is that I have been thus far unable to perform a check using the control without first launching a form and having all the gui elements created. Similarly, we display a splashscreen before the mainform is even launched that the users shouldn't see if there is an update.

The goal is to silently check for updates in the background before the software loads up, if there is an update, install it first, if not continue on and run our program. Using the automatic updater, the user is first displayed a splashscreen, the form loads, which creates the control, which can then be used to check for updates, but then if there's an update, we have to close the program and start again.

I saw in the video tutorial where you talk about using the ClosingForInstall as a guard against loading settings, however, I'm confused by this because, as far as I can tell, the automaticupdater checks for updates asynchronously and fires an event if/when an update is available. It seems like the guard condition will just get passed before the updater can determine if closing is necessary. And it still doesn't solve the problem of not displaying the splashscreen.

So far, getting exit codes that are distinguishable seems like the best solution.

Thanks for all your help,-Erik

Ok, we'll add the commandline switch to wyUpdate. It will be done by early next week.

Ok, the "-quickcheck -justcheck" switch has been added to wyUpdate. It will return 2 if an update is found.

Just update to wyBuild 2.5.15.