Øyvind Bråthen
Øyvind Bråthen

Reputation: 60694

Installing a windows service as another user than Network Service

I am using a self-installing variant to install my windows service. That means I run the exe that makes up the service, and when run it installs itself using the following line of code:

ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });

This works fine, and the service gets added to the list of services. My only problem is that this service gets added with Log On As equal to Network Service. I am doing certain operations from this service that require it to log on as Local System.

How can I make it install itself to run as Local System instead of Network Service?

Upvotes: 0

Views: 854

Answers (1)

L.B
L.B

Reputation: 116118

I think you are using ServiceProcessInstaller. If so, you can set ServiceAccount.LocalSystem to its Account property

Upvotes: 1

Related Questions