Controlling Windows Services via Batch Script

Discussion in 'Windows' started by gpicazo, Nov 25, 2008.

  1. gpicazo

    gpicazo New Member

    Joined:
    Feb 18, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone,

    I am trying to write a batch script for the following deployment scenario:

    I have a list of services (about 10 of them) that run on a remote server (target for deployment). Before deploying any files to the server, I want to stop any of those 10 services if they are running. Then I can copy/override whatever files I need to for the deployment. Once the deployment is complete, I need to restart ONLY those services that were running prior to the deployment.

    I know to use the 'sc' command to stop and start the services, I just don't know how to keep track of which services need to be restarted.

    Any help would be greatly appreciated. A sample that depicts a possible solution would be even better.

    Thank you,
    Genaro
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    48
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice