wuBuild Udpate through window service

Hi,

I was doing update using win form application and it is working fine. But i do not want to show any UI window to user and also i do not want UAC prompt so as per your suggestion I tried to do auto update using window service.

I created window service and put below code into the Onstart event of service.

auBackend = new AutomaticUpdaterBackend(); auBackend.UpdateType = UpdateType.Automatic; auBackend.GUID = "48787287-5a45-4a53-ac28-3fc558931c9d"; auBackend.ReadyToBeInstalled += auBackend_ReadyToBeInstalled; auBackend.UpdateSuccessful += auBackend_UpdateSuccessful; auBackend.UpToDate += auBackend_UpToDate; auBackend.UpdateFailed += auBackend_UpdateFailed; auBackend.Arguments = "-quickcheck -justcheck -noerr"; auBackend.CheckingFailed += new FailHandler(auBackend_CheckingFailed); auBackend.ServiceName = this.ServiceName; auBackend.Initialize(); auBackend.AppLoaded();

if (!auBackend.ClosingForInstall) { // sees if you checked in the last 10 days, if not it rechecks CheckForUpdate();

//Note: Also, since this will be a service you should call // CheckEvery10Days() from an another thread (rather // than just at startup)

//TODO: do your normal service work } timer.Interval = 20 * 60 * 1000; timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); timer.Start();

My timer will check updates after every 20 minutes.

Now when updates founds, before installing new updates, I am killing running applications. But after that my window service stops running and update does not happen.

Can you please help what i am doing wrong

I recommend you use wyUpdate that gives prompts. It's much easier, and it has better usability. For instance, you don't want to kill running instances of your app when your user is using them.

That being said, if you insist on using the AutomaticUpdaterBackend in a Windows Service, then I see a couple things you've done wrong. Firstly, remove the " auBackend.Arguments = "-quickcheck -justcheck -noerr"; " line. The AutomaitcUpdater silently checks and updates. Using those parameters will likely screw things up. Also, Is your service a "LocalService" type or a "LocalSystem" type service? There's a big difference.

Lastly, when you want to install your updates you must call auBackend.InstallNow().

I have removed arguments. Also my service is running under localsystem account. I am doing updates in auBackend_ReadyToBeInstalled event.

public void auBackend_ReadyToBeInstalled(object sender, EventArgs e) { // ReadyToBeInstalled event is called when either the UpdateStepOn == UpdateDownloaded or UpdateReadyToInstall

if (auBackend.UpdateStepOn == UpdateStepOn.UpdateReadyToInstall) { // here we'll just close immediately to install the new version KillRunningApplications(); auBackend.InstallNow(); } }

But I am facing same problem. My service stopped running and nothing happens. Why I want to use window service, because i do not want UAC prompt in window 7 or vista.If you want then i can send .cs file to you by email

Sure send the file to wyatt@wyday.com

today I tried to debug the window service which I have developed to update my software.

I am getting error in auBackend_UpdateFailed event as below

1 processes are running:

(ServiceAutoUpdate.vshost.exe) wyDay.Controls.FailArgs

Now if I close my visual studio project for window service then updates works fine. If I just open my visual studio project for window service and start the service from service manager then I am getting above error.

I know this will not be case when I deploy my service in end user machine. But as a developer it is little bit confusing.

Uncheck the "Enable the Visual Studio hosting process" checkbox:

[attachment=0]vhost.png[/attachment]

Hi,

I am trying to do this too. I am trying to update a winForm application using the windows service. But everytime the windows service stops after calling auBackend.InstallNow() and then nothing is being updated.

May i know if the Windows Service is supposed to be installed in the same directory as my winForm application for the update to happen? and what of the wyUpdate.exe and client.wyc file? is it suppose to be in the same directory aswell?

wyUpdate.exe and the client.wyc need to be in the same folder as your application. Also, if you want the service to be updated too then that also needs to be in your app's folder.

Thanks for the quick reply. The windows service is just for updating the winForm app. It does not have to update itself. So i have taken yr advice and install them in a saparate directory.

Can u explain how the windows service is able to know where the winForm app is located and updates it? Currently after i start the dummy windows service it doesnt do anything. Your help is much appreciated.

The "Your program's folder" in wyBuild corresponds to the folder wyUpdate.exe is sitting in.

Currently after i start the dummy windows service it doesnt do anything.

I'm going to need a lot more information to help you fix this. What commandline switches did you start wyUpdate with? Or are you using the AutomaticUpdater?

Wyatt wrote:> The "Your program's folder" in wyBuild corresponds to the folder wyUpdate.exe is> sitting in.I have copied the wyUpdate.exe and client.wyc file generated into the same folder as where my program is. Is that what u mean?

>

Currently after i start the dummy windows service it doesnt do anything.

> > I'm going to need a lot more information to help you fix this. What commandline switches> did you start wyUpdate with? Or are you using the AutomaticUpdater?

i am using AutomaticUpdater. and i followed exactly what this article said to do: http://wyday.com/wybuild/help/automatic-updates/windows-services-console-apps.phpPlease let me know what else do you need from me.

Are you using the AutomaticUpdater events? Specifically the "CheckingFailed", "DownloadingOrExtractingFailed", "UpdateFailed" events.

This will tell you if anything is wrong. Also, you need to set the "wyUpdateLocation" property because wyUpdate.exe will be in a different folder than your service. It would be easier if you just put the service in the same folder as your application. That way you could update your service later.

I have since implemented all the events that you suggested. and also set the wyUpdateLocation = @"C:\\Program Files\\MyCrappyApp\\wyUpdate.exe". Atleast it is responding now and i got an error thrown by UpdateFailed event saying "Service Auto Update Service was not found on computer". What does this error mean?

Hi, Its working now after i change the service name to reflect the actual service name.

Another question. What if I wanted to use the same windows service to update multiple programs, what would be a good way to do this?. I think the windows service restart each time it updates a program right?

What if I wanted to use the same windows service to update multiple programs, what would be a good way to do this?

This is trickier -- there are a few ways you can do this, but none of them very easy. The best way is to use wyUpdate in standalone mode (see: How to Silently update a Windows Service). Using that article you won't need to restart your service for updates. Plus you can concurrently update multiple apps.

We're making this easier in wyBuild 2.7 (for both developers and IT guys that actually have to manage apps across multiple computers).