Programming Windows Services

Last night I almost made a post with a big mistake. I was thinking about the X-Copy deply in VB.NET and realised that it did not work for Services. I know it does not – but not in that way. With ASP.NET you can overwrite the old copy of an exe even whilst it is running since ASP.NET takes a copy and places it in RAM or something until it is not needed.

But with services they are kept on the disk. And they are locked. So you need to uninstall an old version before adding a new version.

One of the other things that I want to do is to run a program either as a service or with a GUI depending on how the program started. After a lot of searching I found an article on the DotNet 247 Site. Now this is a site I normally hate because they look like one of those horrible search engines that contaminate Google and never have the keywords when you go to the page. But this time I eventually found what I was looking for.

One of the replies states

If the parameter is set, start as a service, if the parameter is not given,

start as a normal executable. Basically in your Sub Main, if the parameter

is given do the ServiceBase.Run else do Application.Run.

Looks good, but being able to automatically determine it would be better. I am starting to ‘GET’ services. Now that is worrying.

Music: Nothing. It is 8:24AM on a sunday morning… Argh