Using UNC Paths for Updates

I am trying to integrate you program into our application to allow updates. Because of the complexity of the updates, i.e. multiple programs, services and databases we have a semi-manual approach. On each customers site, we create a UNC path on the application server, in their we create afolder for each app / service. i.e. \\Srv1\Updates\App1, \\Srv1\Updates\App2, \Srv1\Updates\Srv1 etc.

The when weare sure the database etc, is to the updated version, we copy the updated files to the UNC paths.

My questions are, firstly, you have a file:/// option as a server path, is is acceptable to enert a UNC path in here?

Next, in your configuration project, there only seems to be a way to upload files to FTP or websites, how do I upload to a UNC path?

Next assuming is it possible, we would like each of the apps, on startup to check for updates, and if found, self-update, and restart, is this possible? The apps are stored in c:\Program Files (x86)\Company Name\App1\..., c:\Program Files (x86)\Company Name\App2\... etc.

Finally for my services, the plan is they will check for updates based on an internal timer, if an update is found, the service again should self-update and restart. Again, is this possible?

In both cases, the users do not have a choice to upgrade, it is a corporate requirement. So the upgrade should be automated, silent, and uninteruptable. The updates are usually very small, <10Mb, and because from a UNC path, should be very quick to copy and install. We will only be replacing existing files, or occasionally adding a new dll. We do not want to run installers etc. as a part of the upgrade routine.

I welcome you feedback on the above before we commit to this update tool.

Hey Mark,

My questions are, firstly, you have a file:/// option as a server path, is is acceptable to enert a UNC path in here?

Yes. A UNC path like this:

\\fileserver\share\dir\some file.ext

becomes this:

file://///fileserver/share/dir/some%20file.ext
Next, in your configuration project, there only seems to be a way to upload files to FTP or websites, how do I upload to a UNC path?

We have this done, and it's coming with wyBuild 2.6.18. In the meantime you can just click the "Open the containing folder..." link then copy the files in that folder to your sever.

Next assuming is it possible, we would like each of the apps, on startup to check for updates, and if found, self-update, and restart, is this possible? The apps are stored in c:\Program Files (x86)\Company Name\App1\..., c:\Program Files (x86)\Company Name\App2\... etc.

Yep, this is possible. See the step-by-step walkthrough. There are lots of ways you can integrate wyUpdate and (optionally) the AutomaticUpdater in your apps. The step-by-step walkthrough covers most of the options.

Finally for my services, the plan is they will check for updates based on an internal timer, if an update is found, the service again should self-update and restart. Again, is this possible?

Yep. See "How to Silently update a Windows Service."

In both cases, the users do not have a choice to upgrade, it is a corporate requirement. So the upgrade should be automated, silent, and uninteruptable. The updates are usually very small, <10Mb, and because from a UNC path, should be very quick to copy and install. We will only be replacing existing files, or occasionally adding a new dll. We do not want to run installers etc. as a part of the upgrade routine.

Then it sounds like wyBuild will be a perfect fit.

Tell me if this helps clarify things.

Thanks for the reply, this has helped greatly.

I have now attempte to implement this update method on one of our apps. I want the app to chack for an perform any updates on every startup.

I have added the Automatic Update control on the main form. Set a GUID, then in the form load even handler, I set the server and download location, set the event handlers and forve an update check.

Then if an update is not present we continue the form loading, or if an update is present, we perform the upgrade. These seems fine in theory, but not so well in practice. Sample code below. Can you advise if this is the best way to proceed? or tell me where I am going wrong.

private void FrmMainLoad(object sender, EventArgs e) { if (!String.IsNullOrEmpty(ConfigHelper.Config.UpdateUNC)) { var svr = ConfigHelper.Config.UpdateUNC + @"\RMClient\wyserver.wys"; var path = ConfigHelper.Config.UpdateUNC + @"\RMClient";

if (File.Exists(svr)) { _automaticUpdater1.wyUpdateCommandline = String.Format("-server=\"{0}\" -updatepath=\"{1}\"", svr, path); _automaticUpdater1.UpdateType = wyDay.Controls.UpdateType.Automatic; _automaticUpdater1.UpdateAvailable += new EventHandler(_automaticUpdater1_UpdateAvailable); _automaticUpdater1.UpdateFailed += new wyDay.Controls.FailHandler(_automaticUpdater1_UpdateFailed); _automaticUpdater1.UpToDate += new wyDay.Controls.SuccessHandler(_automaticUpdater1_UpToDate); _automaticUpdater1.ForceCheckForUpdate(); } else { FinaliseLoading(); } } }

private void FinaliseLoading() { try { //finalise startup, and open login form. } catch (Exception error) { ExceptionHandling.LogProblem(error); } }

void _automaticUpdater1_UpToDate(object sender, wyDay.Controls.SuccessArgs e) { FinaliseLoading(); }

void _automaticUpdater1_UpdateFailed(object sender, wyDay.Controls.FailArgs e) { try { throw new Exception(e.ErrorMessage); FinaliseLoading(); } catch (Exception error) { ExceptionHandling.LogProblem(error); throw; } }

void _automaticUpdater1_UpdateAvailable(object sender, EventArgs e) { try { _automaticUpdater1.InstallNow(); } catch (Exception error) { ExceptionHandling.LogProblem(error); } }

Well, if you want to force users to upgrade your app before they can continue, then using wyUpdate as a standalone updater is a better choice. The reason is that the AutomaticUpdater is asynchronous -- that is, it's used best when users are allowed to use the old version while the new version is downloaded and extracted in the background.

wyUpdate as a standalone updater is synchronous. That is, you can force the user to upgrade immediately without using a bunch of threading tricks. See how to use wyUpdate in desktop apps or how to use wyUpdate in a Windows Service.

That being said, if you still want to go the AutomaticUpdater route, then there are a few problems with your code that you need to fix. For starters, the UNC paths aren't formed correct. You need to use forward slashed (/) not backward slashes (\).

Next, you need to have all the initialization code in the form's constructor not in the "FrmMainLoad" method.

OK, we have gone down the route of using the standalone version. Code used below. This basicaly works, the only issue I have is that even withthe /skipinfo argument the app pops-up a dialog box informing about the update, but also asking the user to end processes. Most of my users will freak out if they get a prompt like that. I would prefer no dialog at all, but if I must have a dialog, I definately do not want any prompt asked about ending processes etc. Can you advise please.

Thanks

private static void CheckUpdates(){ try { var svr = ConfigHelper.Config.UpdateUNC + @"\RMClient\wyserver.wys"; var path = ConfigHelper.Config.UpdateUNC + @"\RMClient"; if (File.Exists(svr)) { var exeString = String.Format("\"{0}\\wyUpdate.exe\"", Application.StartupPath); var checkArgs = String.Format("/quickcheck /justcheck /noerr /server=\"{0}\" /updatepath=\"{1}\"", svr, path); int retCode = -1;

using (var checkProcess = new Process()) { checkProcess.StartInfo.Arguments = checkArgs; checkProcess.StartInfo.FileName = exeString; checkProcess.Start(); checkProcess.WaitForExit(); retCode = checkProcess.ExitCode; checkProcess.Close(); } if (retCode == 2) { ExceptionHandling.Info("Updates found and processing."); var updArgs = String.Format("/skipinfo /server=\"{0}\" /updatepath=\"{1}\"", svr, path); using (var updProcess = new Process()) { updProcess.StartInfo.Arguments = updArgs; updProcess.StartInfo.FileName = exeString; updProcess.Start(); updProcess.WaitForExit(); retCode = updProcess.ExitCode; updProcess.Close(); } } else { ExceptionHandling.Info("No updates found"); } } } catch (Exception error) { ExceptionHandling.LogProblem(error); }}

but also asking the user to end processes. Most of my users will freak out if they get a prompt like that. I would prefer no dialog at all, but if I must have a dialog, I definately do not want any prompt asked about ending processes etc. Can you advise please.

You should close your app immediately after launching wyUpdate that way wyUpdate won't see that app as running (and thus won't prompt the user).