I've been trying to create an app that installs a user service and starts it without having to log out and then log in.
I do not understand how to achieve this.
I create a service by calling CreateServiceW the following arguments set (some args omitted).
dwDesiredAccess set to GENERIC_ALL | SERVICE_START
dwServiceType set to SERVICE_USER_OWN_PROCESS
dwStartType set to SERVICE_AUTO_START
This creates the service and I can find it in the Services tab in the task manager but not in Services.
If I try to start the service with StartServiceW I get "Error 1058: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.". If I log out and then log in I get yet another service (that is running) with the same name but with an underscore and some random chars appended to the name.
I get that the service I first created wasn't really the user service and the service that popped in after logging in and out again is the actual user service.
I've tried to find more information about user services but it's very sparse.
So how can I start a user service manually after creation with the win api without having to log out and in again?