Use AutomaticUpdater in Windows Service

I need to implement silent update of working service. I read this post:https://wyday.com/forum/t/346/completely-silent-update/#post-1704and create second (update) service that will stop, update and start working service. In update service I use AutomaticUpdater to check for updates. Code to create control:

AutomaticUpdater _updater = new AutomaticUpdater(); _updater.GUID = "776314EB-185D-40D5-8994-9D7CA14852CF"; _updater.wyUpdateLocation = @"C:\Users\Alexei\AppData\Roaming\Default Company Name\DummyService\wyUpdate.exe";

In timer callback I use this code:

_updater.ForceCheckForUpdate()

but first launch of this method throw NullReferenceException. Stack trace:

System.NullReferenceException was caught Message=Object reference not set to an instance of an object. Source=AutomaticUpdater StackTrace: at wyDay.Controls.AutomaticUpdater.forceCheck(Boolean recheck, Boolean forceShow) at wyDay.Controls.AutomaticUpdater.ForceCheckForUpdate(Boolean recheck) at wyDay.Controls.AutomaticUpdater.ForceCheckForUpdate() at DummyUpdateService.DummyUpdateService.TimerCallbackFunc(Object target) in C:\Users\Alexei\documents\visual studio 2010\Projects\DummyService\DummyUpdateService\DummyUpdateService.cs:line 90 InnerException:

Next launches of this method always returns false, but update available (uploaded to local web server and checked with wyUpdate).So I have some questions:1. Is it possible to use AutomaticUpdater in windows service? How to use it (sample code or some tips) if is it possible?2. In the post I linked above you say that you working on wyUpdate as windows service in wyBuild 2.8. Can you provide some term when you plan to release this version?

1. Is it possible to use AutomaticUpdater in windows service? How to use it (sample code or some tips) if is it possible?

The AutomaticUpdater requires either a Form (Windows Forms) or a Window (WPF) to run. A windows service has neither. That being said, you can run wyUpdate as a standalone silent updater from a Windows Service. See How to Silently Check for Updates.

2. In the post I linked above you say that you working on wyUpdate as windows service in wyBuild 2.8. Can you provide some term when you plan to release this version?

We're trying to get it out by the end of 2010.

I see that wyUpdater can silent check for updates and when updates available it appear (or return 2 with -justcheck parameter) for user agreement to update. Isn't it? Thus it is not a silent update because there are some interaction with user. May be wyUpdater has additional parameters to not show itself when updates available and install updates without appear for user?

We can't make the updater completely silent - UAC elevation is one reason. But we can add an another commandline option to skip the "update changes" step if you want.

Is this something that would solve your problem (even temporarily)? Or would you rather wait for the properly implemented completely silent background service updater.

I download source code of wyUpdate and make some changes for silent update (no UAC prompt because wyUpdate launch by my update service, that running with admin rights) so I resolve my problem.Now I have a question about rights for using modified wyUpdate in my application. I'm not familiar with BSD license under you distribute wyUpdate, so I want to know if I leave all copyrights can I use modified by myself version of wyUpdate?

so I want to know if I leave all copyrights can I use modified by myself version of wyUpdate?

Yes. That's almost precisely what it says in the BSD license.

On a related note, since you're building your own version of wyUpdate, you should probably read the How to make a custom version of wyUpdate article. It tells how to maintain self-updates of your own version.

wyBuild 2.6.11 is now out. We now fully support silently updating services either with wyUpdate in standalone mode or, if your service is .NET, use the AutomaticUpdater in your service.