How to install the service under a different account than the LocalSystem account using the Win32 API?

How to install the service under a different account than the LocalSystem account using the Win32 API?

I am using the following code to install the service. I want to install this service under a different account. The last two parameters accept a username and password, but when I give it that way, it gives an error. Is there any specific way to provide username and password here?

IntPtr sv_handle = CreateService(sc_handle, svcName, svcDispName,
                     SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
                     SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
                     svcPath, null, 0, null, null, null);
+3
source share
1 answer

What format do you use for lpServiceStartName?

machinename\\username ( .\\username), , domainname\\username.

+1

Source: https://habr.com/ru/post/1746332/


All Articles