views:

20

answers:

2

I have a simple Windows Service hosting a WCF Service. I want to run the Windows Service under the LocalService account (or even the NetworkService account). However when I try to start it under either of these accounts it starts then immediately stops. It starts and runs OK under the LocalSystem account. Any thoughts as to how to work out why it will not stay running under LocalService or NetworkService.

Thanks,

David

A: 

LocalSystem has extensive privileges on the local machine while LocalService and NetworkService have minimum privileges. So this sounds very much like your service needing some privileges that LocalService doesn't have. As marc_s says in his comment, the first step should be to check the event viewer to see if there are any relevant error messages in there.

If that doesn't help, try adding in some exception handling around the startup code in the service and log any exceptions to the Event Log, hopefully that would then give you enough information to figure out what it is that you're doing that requires higher privileges.

ho1
A: 

Thanks to the suggestions to check the event log from marc_s and ho1 I found out that I needed to add a namespace reservation as follows:

netsh http add urlacl url=http://+:1239/BOBPersistenceServer/ user="Local Service"

See http://msdn.microsoft.com/en-us/library/ms733768.aspx and http://msdn.microsoft.com/en-au/magazine/cc163531.aspx for more details.

daveywc