Controlling Windows Services via Batch Script

gpicazo's Avatar, Join Date: Feb 2008
Newbie Member
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
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
http://windowsxp.mvps.org/listproc.htm