cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
werdna
Level 2

ServiceAddService question (InstallScript project)

I am trying to install a service with specific username/pwd. Here is the function I am using. If I comment out the SERVICE_ISPARAMS.xxx lines it works fine and installs the service. Though it does it as the local system account. As soon as I add those lines it fails. I am installing to Windows 7 x64 and 2008 R2 x64 machines. Do I need to convert the string to numbers or am I screwed on Win7?

function AddService()
string szServiceStartName, szPassword;
string szServiceName, szServiceDisplayName, szServiceDescription, szServicePathFile, szStartServiceArgs;
POINTER pUser, pPW;

begin

//Debug messages to make sure information was passed from other function.
//MessageBox(svSVRUser, INFORMATION);
//MessageBox(svSVRPwd, INFORMATION);

pUser = &svSVRUser;
pPW = &svSVRPwd;

//ServiceInitParams ();
//SERVICE_IS_PARAMS.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
//SERVICE_IS_PARAMS.lpServiceStartName = pUser;
//SERVICE_IS_PARAMS.lpPassword = pPW;


szServiceName = "XXXService";
szServiceDisplayName = "XXXService";
szServiceDescription = "Automatically downloads profile's plugins from Configuration services and starts them";
szServicePathFile = TARGETDIR^"\\Service.exe";
if (!ServiceExistsService ( szServiceName )) then
if (!ServiceAddService(szServiceName, szServiceDisplayName, szServiceDescription, szServicePathFile, FALSE, ""))then
MessageBox("Service created successfully!", INFORMATION);
else
MessageBox("Service could not be created!", SEVERE);
endif;
endif;
end;
Labels (1)
0 Kudos
(4) Replies
Kramer
Level 3

Short answer? It's broke.

http://community.flexerasoftware.com/showthread.php?t=195514

I have a support case open since last November that they STILL can't give me an answer to why it broke in 2011 or when it might be fixed.
0 Kudos
instTst
Level 4

I'm having the exact same problem.

Are there any workarounds for this problem? I don't mind adding code to the script as long as I can fix this problem.
0 Kudos
instTst
Level 4

Hey everyone,

The solution for me was that I needed an escape character. I forgot that I was hard coding a string value for the username and '\' needs an escape character.

Regards,

J
0 Kudos
manomatt
Level 8

try to use this api "SetServiceRunAs" by including the isinst.dll to your project.


if(useDLL(SUPPORTDIR ^ "isinst.dll") = 0)then
nResult = SetServiceRunAs(serviceName, userName, pwd);

get the dll from here
http://www.installsite.org/pages/en/isp_svc.htm
0 Kudos