Batch file to Stop/Start Service

I would like to restart a service by using a service account in batch. The batch file will need to read over 300 file services from a text file and stop the service. A second file will start the service in the same manner.

You can do this using a combination of for /f and “net start” and “net stop” commands.

for /f %%A in (text.file) do net start %%A
for /f %%A in (text.file) do net stop %%A

If you have quotes in filename or so use the backquote option for for command. type for /? for help on for.

Leave a Reply

You must be logged in to post a comment.