views:

191

answers:

3

Hi,

If I have a windows service on a server, what is 'best practise' for updating the service? (say there was a bug in it, or I need to ad more features to it).

Is there a way I could shutdown the service, patch it and get it up and running in a more automated way?

(any links with code would be great)

A: 

Well, you could always up the version on the installer (if you used one) and run that, from my experience it overlays old versions with the newer one.

Or you could simply shut down the service, copy in the new .exe (and dependencies if any) and start it back up. This could all be done with scripting and the NET start/stop functions I would imagine.

I'm sure there is a better way to do it than this though...

thismat
A: 

InstallShield supports Windows Services. Leveraging installers will make your task much simpler.

Ray
+1  A: 

Depends how your service is written - monolith EXE - you'll need to stop and restart it using a process of choice e.g. Installer, Script + Service Control, batch and NET STOP/START etc.

If you structure it a little differently e.g. bootstrap EXE loading your service implementation as modules that can be unloaded/reloaded then you can have a different conversation. This is of course a quite a bit more complicated.

I've had some success in C# with a hosting solution like this, similar conversation here:

http://stackoverflow.com/questions/106765/i-want-my-c-windows-service-to-automatically-update-itself#106799

stephbu