.NET Programmer Thoughts

Tuesday, February 08, 2005

More on Windows Services

I found a problem. My service was supposed to monitor an process (DBMSAutoRecover.exe) and make sure that it was always running. If it found it wasn't running, then it was supposed to start it. If it couldn't start it, then it would send an email.

Here's the problem. The process I was monitoring has a user interface. So when the service started it, you couldn't see it! So I did some searching and found out that I could go to my service (DBMSWatcher.exe) and right click on it and go to the properties window. Then on the Log On tab, check the box "Allow service to interact with desktop". When I restarted the service and the server launched DBMSAutoRecover, you could see it! But it was running under a SYSTEM account.

Now, let me complicate things even more. DBMSAutoRecover monitors another application named DBMS. DBMS is an access application that does all kinds of things. Once of which is monitor an Inbox for email. Well, if DBMSAutoRecover is running under a SYSTEM account and then has to start DBMS then DBMS is running under a SYSTEM account. When it's running as a system account, it doesn't seem to be able to connect to that Inbox.

So then I noticed that I could have the server start as a specific user. Cool! Then everything would work. But when I did that I lost the option of allowing the service to interact with the desktop. Not so cool!

So I gave up and my service will just send an email if it finds that DBMSAutoRecover isn't running.

Also I read tons of stuff about how it's not safe to allow a service to interact with the desktop. A SYSTEM account as full privileges on the machine. Then you have a user interface that has full access to the machine. No so good.