Posted 06 June 2007 - 13:36
Group: Full Members
Posts: 1
Member No.: 13782
Joined: 2007-06-06
I spent quite a bit of time hunting this one down as well. There may be other ways to do it but the basic idea is to create a new dialog which will prompt the user for the login credentials that you want to run the service as. Those credentials will be piped into a PROPERTY, which you then read via an installscript custom action, and add the service using the following calls:
ServiceAddService ( szServiceName, szServiceDisplayName, szServiceDescription, szServicePathFile, bStartService, szStartServiceArgs );
Something like this:
nResult = MsiGetProperty(hMSI, "UserName",szUserName, nSize);
nResult = MsiGetProperty(hMSI, "Password",szPassword, nSize);
ServiceInitParams ();
SERVICE_IS_PARAMS.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
SERVICE_IS_PARAMS.lpServiceStartName = szUserName;
SERVICE_IS_PARAMS.lpPassword = szPassword;
nReturn = ServiceAddService ( szServiceName, szServiceDisplayName, szServiceDescription, szFileName, bStartService, szStartServiceArgs );