How to: Specify the Security Context for Services
By default, services run in a different security context than that of the logged-in user. Services run in the context of the default system account, called LocalSystem, which gives them different access privileges to system resources than the user. You can change this behavior to specify a different user account under which your service should run.
You set the security context by manipulating theproperty for the process within which the service runs. This property allows you to set the service to one of four account types:
For more information, see theenumeration.
To specify the security context for a service
After creating your service, add the necessary installers for it. For more information, see.
In the designer, access the ProjectInstaller class and click the service process installer for the service you are working with.
For every service application, there are at least two installation components in the ProjectInstaller class — one that installs the processes for all services in the project, and one installer for each service the application contains. In this instance, you want to select.
In the Properties window, set the Account to the appropriate value.