Re: Batch script for maintaing remote services

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



*** See below.

"test" <harpreet.noni@xxxxxxxxx> wrote in message
news:26363214-a7e3-4000-932a-e8219a2c7aec@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Greetings,

I want to maintain (stop/start) services on remote machine in orderly
fashion. The requirement is that the next service should only be
started/stopped when previous service has stopped/started completely.
I am using Windows xp. I am able to come up with something like below:

REM ** To stop services on remote machine **

start /wait sc \\server_name stop service_name1
start /wait sc \\server_name stop service_name2

REM ** To start services on remote machine **

start /wait sc \\server_name start service_name1
start /wait sc \\server_name start service_name2


Is it true that above command means that service_name2 will only
stop/start when the first service i.e service_name1 gets
stopped/started completely?
*** Probably, but if this is what you want then you should
*** drop the "start" command altogether:
*** sc \\Server_Name stop service_name1

Also, I have one more issue. Sometimes when the service is getting
stopped, it goes into a "intermediate" state as STOPPING. In this
case, I want to kill this service before sc command go on stopping
next services.
*** In such cases you need a loop, e.g. like so:
***
*** sc \\Server_Name stop service_name1
*** :Loop1
*** ping localhost -n 10 > nul
*** sc \\Server_Name query service_name1 | find /i "stopped || goto Loop1
***
*** You should also add a loop counter in order to deal
*** with cases where the service can't be stopped.

Can someone please help me here. I have searched enough and not able
to come to any conclusion.

TIA


.



Relevant Pages

  • Batch script for maintaing remote services
    ... I want to maintain (stop/start) services on remote machine in orderly ... fashion. ... Is it true that above command means that service_name2 will only ...
    (microsoft.public.windowsxp.general)
  • Re: Making a script into a service
    ... These scripts kick off other programs that need to run ... on the server. ... make them into one service that i can stop/start with one command such ... one command instead of pgrep the scripts and killing them manually. ...
    (comp.os.linux.misc)