You are on page 1of 1

Copy the following script in a notepad file and save it as .bat file.

This script will stop and start a service on a remote PC. In the following example remote PC name is USPSV2 and the services to be stopped and started are SQLAgent$SBC and MSSQL$SBC. To get the name of a service goto Run and type services.msc. The list of services will appear. Right click and goto the properties of any service to display the Service name.The same service name should be given in this script to restart it.

sc.exe "\\USPSV2" stop SQLAgent$SBC @ECHO OFF SET COUNT=1 :LOOP1 IF %COUNT% == 5000 GOTO END1 SET /A COUNT=COUNT+1 GOTO LOOP1 :END1 @ECHO ON sc.exe "\\USPSV2" stop MSSQL$SBC @ECHO OFF SET COUNT=1 :LOOP2 IF %COUNT% == 5000 GOTO END2 SET /A COUNT=COUNT+1 GOTO LOOP2 :END2 @ECHO ON sc.exe "\\USPSV2" start MSSQL$SBC @ECHO OFF SET COUNT=1 :LOOP3 IF %COUNT% == 5000 GOTO END3 SET /A COUNT=COUNT+1 GOTO LOOP3 :END3 @ECHO ON sc.exe "\\USPSV2" start SQLAgent$SBC

You might also like