PDA

View Full Version : Replace a running service



NewsArchive
11-08-2008, 01:55 AM
Hi All,

I am trying to create an install that will first stop a running
service and then of course, replace it. At the end of the script, I want to
restart the service again.

I have added a stop service script function using the edit service script
function. It was added just after the Include
Common Definitions. I put an 8 second sleep after that to give it time to
stop.

This is not working. Is this not the right approach? I entered the program
name (myservice.exe in the description area.

Also, I have added a start service at the end but do not
think this is working either.

--
Ron Childs
C6.3 9056 ABC

NewsArchive
11-08-2008, 01:56 AM
Hi Ron,

> I am trying to create an install that will first stop a running
> service and then of course, replace it. At the end of the script, I want
> to restart the service again.
>
> I have added a stop service script function using the edit service script
> function. It was added just after the Include
> Common Definitions. I put an 8 second sleep after that to give it time to
> stop.
>
> This is not working. Is this not the right approach? I entered the
> program name (myservice.exe in the description area.
>
> Also, I have added a start service at the end but do not
> think this is working either.

A quick suggestion. There is an install/start/stop etc. demo script in the
Examples package. And it's a good idea to check the return values of the
functions in your script to see what fails/succeeds.

Please keep us posted.

Friedrich

NewsArchive
11-09-2008, 03:44 AM
Ron,

This is what I use :

Detect and stop a running service:

Set Variable %ECNLM_SERVICE_RUNNING% to FUNCTION:Check Service "EC_NLM"

If %ECNLM_SERVICE_RUNNING% Equals "1" Then
Loop (4 Times)
Stop Service "EC_NLM"
Sleep for "3" seconds
Set Variable %_SB_RETURN% to FUNCTION:Check Service "EC_NLM"
If %_SB_RETURN% Equals "0" Then
Break Loop
End
End
End


Restart the service:

If %ECNLM_SERVICE_RUNNING% Equals "1" Then
Start Service "EC_NLM"
End

michael d. brooks

NewsArchive
11-09-2008, 03:45 AM
Thanks Michael,

I will have a look at that along with the sample projects
that Freiderich recommended.

--
Ron Childs
C6.3 9056 ABC

NewsArchive
11-11-2008, 02:49 AM
Friedrich,

Got it working. Part of my problems was I had setup
a test folder in which the program was running. I had not
installed it as a service so therefore, the stop service was not working.
Once installed as a service, all worked as advertised. Thanks again for
your help.

--
Ron Childs
C6.3 9056 ABC