cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
coedindigo
Level 5

Installing Windows Service Fails??

I am using IS2008 Pre . My project type is InstallScript. I wanted to install windows service called abcd.exe on windows(Vista).

I am trying to installservice using following lines of code. after running setup i can see the service in Service Control and whenever i try to START it it fails saying that Windows cannot find the service. I tried rebooting the machine but it still fails to start.

function OnMoved()
begin

ServiceAddService("ABC.exe","ABC","MyService",TARGETDIR,TRUE,"");


SERVICE_IS_PARAMS.dwServiceType =
SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
SERVICE_IS_PARAMS.dwStartType = SERVICE_AUTO_START;
SERVICE_IS_PARAMS.dwErrorControl = SERVICE_ERROR_IGNORE;




ServiceStartService("ABC.exe","");

Am I doing it right way?
Any help will be highly appreciated.

Thanks in advance.

Kurt.
Labels (1)
0 Kudos
(6) Replies
RobertDickau
Flexera Alumni

You might double-check the arguments to ServiceAddService: the first argument is apparently the internal service name (such as "ABC"); second and third the display name and description in the Services administrative tool; fourth the full path to the service executable (TARGETDIR^"abc.exe", perhaps?); and so on.

Since the service appears in the Services administrative tool, perhaps look at its properties and see what looks wrong?

The ServiceAddService help topic has more information, including information about interpreting error codes.
0 Kudos
coedindigo
Level 5

Robert,

I made the changes suggested by you,

Now my code looks like

ServiceAddService("ABC","XYZ","Service Agent",TARGETDIR^"\\A\\B\\ABC.exe",TRUE,"");


SERVICE_IS_PARAMS.dwServiceType =
SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
SERVICE_IS_PARAMS.dwStartType = SERVICE_AUTO_START;
SERVICE_IS_PARAMS.dwErrorControl = SERVICE_ERROR_IGNORE;


ServiceStartService("ABC.exe","");

Now i can see the Service in Service Control with startup type set to Automatic(instead of Disabled as in previous case) , but whenever i access the properties it doesnt show full path to executable. In this case it is
C:\A\B\C instead of C:\ProgramFiles\B\C\Service.exe.

my TARGETDIR=PROGRAMFILES ^"B\\C".

Also when i try to start service it says cannot Start service on Local Computer, however my service installs just fine using installutil manually from the targetdir.

What is wrong am i doing?

Thanks a ton
0 Kudos
RobertDickau
Flexera Alumni

One thing is, I think the argument to ServiceStartService should be the internal service name used as the first argument to ServiceAddService.

If you display the value of TARGETDIR (or better yet, TARGETDIR^"A\\B\\abc.exe") before calling ServiceAddService, is the value correct?
0 Kudos
coedindigo
Level 5

Robert I checked the value of TARGETDIR..its correct.

I am now trying following piece of code:

ServiceAddService("ABC","ABC","Service Agent",TARGETDIR^"ABC.exe",TRUE,"");


SERVICE_IS_PARAMS.dwServiceType =
SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
SERVICE_IS_PARAMS.dwStartType = SERVICE_AUTO_START;
SERVICE_IS_PARAMS.dwErrorControl = SERVICE_ERROR_NORMAL;




if ServiceStartService("ABC","")< ISERR_SUCCESS then
MessageBox("Error Starting Service",SEVERE);
endif;

and i get "Error Starting Service" error.
I have no idea whats wrong with this.
Any more suggestion?

Thanks
Manas.
0 Kudos
RobertDickau
Flexera Alumni

If you haven't yet, please see the InstallShield help for that function for information about how to interpret specific error codes (the return value from ServiceStartService, for example)...
0 Kudos
GetExp
Level 6

coedindigo wrote:
Robert I checked the value of TARGETDIR..its correct.

I am now trying following piece of code:

ServiceAddService("ABC","ABC","Service Agent",TARGETDIR^"ABC.exe",TRUE,"");


SERVICE_IS_PARAMS.dwServiceType =
SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
SERVICE_IS_PARAMS.dwStartType = SERVICE_AUTO_START;
SERVICE_IS_PARAMS.dwErrorControl = SERVICE_ERROR_NORMAL;




if ServiceStartService("ABC","")< ISERR_SUCCESS then
MessageBox("Error Starting Service",SEVERE);
endif;

and i get "Error Starting Service" error.
I have no idea whats wrong with this.
Any more suggestion?

Thanks
Manas.


Did you use the parameter SERVICE_IS_PARAMS.nStartServiceWaitCount
with the value 0? Possibly try this. If the problem occurs then please post the installation log file.
0 Kudos