This article can be useful for users who want to set multiple services on remote computers. The following steps can be performed to accomplish this:
Steps:
1. Create a text file: Comps.TXT
2. Put all the computer names in it.
3. Create another text file and put all the services you want to start: Services.TXT
4. Create a batch file: SetServices.CMD and put the following lines in it:
- @ Echo OFF
- setlocal enabledelayedexpansion
- FOR /F "Tokens=*" %%L IN (Comps.TXT) DO (
- SET CompName=%%L
- FOR /F "Tokens=*" %%L IN (Services.TXT) DO SC \\!CompName! Start %%L auto
- )
- )
5. Finally, run the SetServices.CMD from a command window.
The above script start the services mentioned in the Services.TXT file on computers mentioned in the Comps.TXT file.
Hi I want to stop and start services on multiple servers with batch file