Reputation: 364
I have a windows service, written in c++, and I need it to start with privileged rights eg. administrator or system. The service needs access to %SYSTEMROOT%, %USERPROFILES%, %TEMP% and so on. The service will run under windows XP and 7.
The service is going to be deployed using GPOs, so local accounts can't be used.
Can I set the user in the service itself? If, how? And if not, how can I deploy it using GPO?
Any ideas? Thanks
Upvotes: 1
Views: 988
Reputation: 55760
You don't set the user from the service (i.e. from code). Rather you set the user account that runs the service when you deploy/install it.
Your options for installing a Windows service are
sc
command)When using the sc command you can set the user account for a service using the following command:
sc config <servicename> obj= <accountname> password= <password>
When deploying via Windows Installer you can configure the user account in the MSI.
Then, you can use Group Policy to remotely install/deploy your service either using the MSI or via the other method.
Upvotes: 1