cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
pcs-doa
Level 3

ServiceAddService doesn't create service

Hi all,
i want to create a service using installScript but nothing happens. I use the following Code and if i get the GetExtendedErrInfo no error will be displayed but i can't see the service in the services.exe application.


function createDBService(hMSI)
// To Do: Declare local variables.
STRING StartCmd,StopCmd,startTimeout,stopTimeout, serviceName, serviceNameTxt,svScriptFile,svError,szName,svResult,svValue, serviceUser,servicePassword, serviceDependency;
INT startBuffer,stopBuffer,starttBuffer,stoptBuffer,serviceBuffer,serviceBuffer1,serviceBuffer2,serviceBuffer3,nvLineNumber,nvError, nResult,nResult2;
begin

startBuffer=1000;
stopBuffer=1000;
starttBuffer=1000;
stoptBuffer=1000;
serviceBuffer=1000;
serviceBuffer1=1000;
serviceBuffer2=1000;
serviceBuffer3=1000;

// get properties
MsiGetProperty(hMSI,"STARTCMD",StartCmd,startBuffer);
MsiGetProperty(hMSI,"STOPCMD",StopCmd,stopBuffer);
MsiGetProperty(hMSI,"STOPTIMEOUT",stopTimeout,stoptBuffer);
MsiGetProperty(hMSI,"STARTTIMEOUT",startTimeout,starttBuffer);
MsiGetProperty(hMSI,"AA_SERVICE_NAME",serviceName,serviceBuffer);
MsiGetProperty(hMSI,"AA_SERVICE_DESC",serviceNameTxt,serviceBuffer1);
MsiGetProperty(hMSI,"AA_USER_NAME",serviceUser,serviceBuffer2);
MsiGetProperty(hMSI,"AA_PASSWORD",servicePassword,serviceBuffer3);

MessageBox(serviceName + " " + serviceNameTxt + " " + serviceUser + " " + servicePassword,WARNING);

ServiceInitParams ();


SERVICE_IS_PARAMS.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
SERVICE_IS_PARAMS.dwStartType = SERVICE_AUTO_START;
SERVICE_IS_PARAMS.dwErrorControl = SERVICE_ERROR_IGNORE;
SERVICE_IS_PARAMS.lpServiceStartName = &serviceName;
SERVICE_IS_PARAMS.lpPassword = &servicePassword;

nResult = ServiceAddService( serviceName, serviceNameTxt, serviceNameTxt, TARGETDIR ^ "myexe.exe", FALSE, "" );


if (nResult < ISERR_SUCCESS) then
GetExtendedErrInfo ( szName, nResult, nResult2 );
NumToStr ( svResult, nResult );
NumToStr ( svValue, nResult2 );
MessageBox ("Can not install Application Server service.\n" +
"\n Script: " + szName +
"\n Line: " + svResult +
"\n Error#: " + svValue +
"\n Error: " + FormatMessage (nResult2), SEVERE);
else
MessageBox("Successfully creating service",WARNING);
endif;

if(ServiceExistsService(serviceName) == TRUE)
then
MessageBox("Successfully creating service",WARNING);
endif;


end;


Every time i get into the nResult < ISERR_SUCCESS section and the message says:

---------------------------
ABC - InstallShield Wizard
---------------------------
Can not install Application Server service.

Script: C:\CodeBases\isdev\Script\ISRT\Src\Service.rul
Line: 103
Error#: 0
Error: Der Vorgang wurde erfolgreich beendet.


---------------------------
OK
---------------------------

but no service exists!!! Any ideas?
Labels (1)
0 Kudos
(1) Reply
pcs-doa
Level 3

I found an other solution instead of using ServiceAddService.
I have created the service in Components view and then edit all my "variable" fields like username, password and description in the Direct Editor (Service Install table). I only type my properties with [ and ] in the appropriate column of the table.

But, no if i want to uninstall my Programm including the service, my service will not be uninstalled (Uninstall is selected in the Components Service Event)
Any idea?
0 Kudos