Use ServiceController to start service with different account

I am using a class ServiceController

to start a (installed) installed service, for example:

var newServiceController = new ServiceController("theNameOfMyService");
newServiceController.Start();

      

The problem is that the service always runs under the local system account, and instead I want it to run under my account.

Can anyone tell me how to use ServiceController

to run the service under a different account?

0


a source to share


2 answers


I don't think you can ... the credentials for the service are provided during installation, or alternatively using the Service.msc snap-in in



Service controller can only start / stop a pre-installed service

+3


a source


Your ServiceProcessInstaller instance has a property called Acount, Password and Username, you can use these properties to set who is running how.



0


a source







All Articles