wyDay blog  |  Downloads  |  Buy
LimeLM
wyBuild
Support forum
wyDay blog
wyDay Home

Stopping a service before update

AdiGri

Hello,

I have a .Net application that between other executables, has a service that may have to be updated. Before being able to replace it, the service has to be stopped. Would I be using one of the events raised by AutomaticUpdater, such as ReadyToBeInstalled (and stop the service myself, before the update takes place and restart it using the UpdateSuccessful event)?

Jun 28, '10permalink

We plan to add this directly in wyBuild in the future, but yes, for now you need to stop the service within your own code before it can be updated. You can do this a few ways (including using AutomaticUpdater events), but by far the best way is this:

Stop the services before updating using a batch file

Simply add 2 batch files to your update in the Temporary folder. One batch file will stop the service before an update. The other batch file will stop the service after an update:

[attachment=0]executing-batch.png[/attachment]

Simply check the "Execute file" checkbox to execute the batch files. Read more about Executing files in your update. There are several article online describing how to start and stop services as part of a batch file. Here are a couple that I found in a quick search:

Tell me if this helps.

Jun 28, '10permalink

Hello,

I have finally tried to use these suggestions and I found that wyUpdate is first asking me close the process (the actual service) and only after that is running the batch file that was configured to stop it. I've put a "PAUSE" command in the batch file just to see when it runs. The "stop_service.cmd" file that I use is configured in wyBuild to be executed before the update begins and to wait for the executions to finish before continuing. Am I doing something wrong?

The start_service.cmd works fine and at least the service is restarted even though the user has to kill the process during the update.

Aug 26, '10permalink

You're right, there's no proper way to update services. We're going to add this in wyBuild 2.6.8 or 2.6.9.

Aug 27, '10permalink

Thank you the reply. I will try to see if I can embed the service stopping/restarting in the application itself before the AutomaticUpdater starts.

Aug 27, '10permalink

Now in wyBuild 2.6.7 you can Start and Stop services. Simply go to the "Update Actions" and add an action to stop the services before the update, and add another action to start the services after the update.

See Starting and Stopping Windows Services.

Sep 30, '10permalink
jake

Woot! This is great, thanks.

Oct 4, '10permalink