Reputation: 210080
I'm using the ServiceController
class to start a (custom) installed service, like this:
var newServiceController = new ServiceController("theNameOfMyService");
newServiceController.Start();
Trouble is, 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 a service under a different account?
Upvotes: 0
Views: 2697
Reputation: 7512
On the ServiceProcessInstaller instance for you service there is a property called Acount, Password and Username, can use these properties to set who the service runs as.
Upvotes: 0
Reputation: 44268
I don't think you can... the credentials for the service are provided at install time or alternatively via the Service.msc snap in
The service controller can only start/stop a pre-installed service
Upvotes: 3