Results 1 to 5 of 5

Thread: Replace a running service

  1. #1

    Default Replace a running service

    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

  2. #2

    Default Re: Replace a running service

    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

  3. #3

    Default Re: Replace a running service

    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

  4. #4

    Default Re: Replace a running service

    Thanks Michael,

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

    --
    Ron Childs
    C6.3 9056 ABC

  5. #5

    Default Re: Replace a running service

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •