Stop and Start SAP and Related Services from the Command Line Scripts.
Here is a batch file script I wrote for our SAP admins to start and stop SAP instance and all related services.. It actualy disables the services after it stops, and they dont get started accidently.. This script can be applied to many operational needs… It also outputs to a log file so our SAP admins can verify that all the services started. Hope you find it usefull.
“ = QUOTES
Script 1 = SAPSERVICESTART.BAT
echo *********************************************************** >> c:\scripts\log.txt
echo START SCRIPT >> c:\scripts\log.txt
echo %date% %time% >> c:\scripts\log.txt
echo *********************************************************** >> c:\scripts\log.txt
D: >> c:\scripts\log.txt
cd D:\usr\sap\BWT\SYS\exe\run >> c:\scripts\log.txt
sc config “MSSQLSERVER” start= auto >> c:\scripts\log.txt
NET START MSSQLSERVER /YES >> c:\scripts\log.txt
sc config “SQLSERVERAGENT” start= auto >> c:\scripts\log.txt
NET START SQLSERVERAGENT /YES >> c:\scripts\log.txt
sc config “SAPBED_10″ start= auto >> c:\scripts\log.txt
NET START SAPBED_10 /YES >> c:\scripts\log.txt
sc config “SAPOSCOL” start= auto >> c:\scripts\log.txt
NET START SAPOSCOL /YES >> c:\scripts\log.txt
echo name=BWT nr=10 SAPIDAHOST=SAPTSTBWI >> c:\scripts\log.txt
startsap name=BWT nr=10 SAPIDAHOST=SAPTSTBWI >> c:\scripts\log.txt
echo *********************************************************** >> c:\scripts\log.txt
echo END START SCRIPT >> c:\scripts\log.txt
echo %date% %time% >> c:\scripts\log.txt
echo *********************************************************** >> c:\scripts\log.txt
Script2 = SAPSERVICESTOP.BAT
echo *********************************************************** >> c:\scripts\log.txt
echo STOP SCRIPT >> c:\scripts\log.txt
echo %date% %time% >> c:\scripts\log.txt
echo *********************************************************** >> c:\scripts\log.txt
D: >> c:\scripts\log.txt
cd D:\usr\sap\BWT\SYS\exe\run >> c:\scripts\log.txt
echo name=BWT nr=10 SAPIDAHOST=SAPTSTBWI >> c:\scripts\log.txt
stopsap name=BWI nr=10 SAPIDAHOST=SAPTSTBWI >> c:\scripts\log.txt
NET STOP SAPBWI_10 /YES >> c:\scripts\log.txt
sc config “SAPBWI_10″ start= disabled >> c:\scripts\log.txt
NET STOP SAPOSCOL /YES >> c:\scripts\log.txt
sc config “SAPOSCOL” start= disabled >> c:\scripts\log.txt
NET STOP MSSQLSERVER /YES >> c:\scripts\log.txt
sc config “MSSQLSERVER” start= disabled >> c:\scripts\log.txt
NET STOP SQLSERVERAGENT /YES >> c:\scripts\log.txt
sc config “SQLSERVERAGENT” start= disabled >> c:\scripts\log.txt
echo *********************************************************** >> c:\scripts\log.txt
echo END STOP SCRIPT >> c:\scripts\log.txt
echo %date% %time% >> c:\scripts\log.txt
echo *********************************************************** >> c:\scripts\log.txt
LOG FILE = log.txt
***********************************************************
STOP SCRIPT
Sun 02/25/2009 15:49:55.79
***********************************************************
name=BWT nr=10 SAPIDAHOST=SAPTSTBWI
STOPSAP executed succesfully
name=BWT nr=01 SAPIDAHOST=SAPTSTBWI
STOPSAP executed succesfully
The SAPBWI_10 service is stopping.
The SAPBWI_10 service was stopped successfully.
[SC] ChangeServiceConfig SUCCESS
The SAPOSCOL service was stopped successfully.
[SC] ChangeServiceConfig SUCCESS
The following services are dependent on the MSSQLSERVER service.
Stopping the MSSQLSERVER service will also stop these services.
SQLSERVERAGENT
The SQLSERVERAGENT service is stopping.
The SQLSERVERAGENT service was stopped successfully.
The MSSQLSERVER service is stopping.
The MSSQLSERVER service was stopped successfully.
[SC] ChangeServiceConfig SUCCESS
[SC] ChangeServiceConfig SUCCESS
***********************************************************
END STOP SCRIPT
Sun 02/25/2009 15:50:32.67
***********************************************************
