on 09-04-2014 12:25 PM
Dear expetrs,
I have a SAP Instance installed on the same server where the SAP MC is. I want to have the instance to stop automatically when the server reboot ( after installing updates files for example)
anybody know how I can do that?
My server runs windows server 2008 and the SAP system manager is v1.0 the MC is v.3.0
thx in advance
You can use this script if you run on Oracle, you have to adjust some parameters:
@ECHO OFF
setlocal
set THISHOST=<server>
set LOGFILE=%THISHOST%_stopsap_neu.log
set LOCAL=<SID>
set MYSID=<SID>
set SYSNUM=<SYSNR>
set CSYSNUM=<Central Services SYSNR>
set MYSAPPROGDIR=\\%THISHOST%\sapmnt\%MYSID%\SYS\exe\uc\NTAMD64
set MYNTREGCMD=%MYSAPPROGDIR%\ntreg2cmd %MYSID%
set MYDBSTOPCMD=%MYSAPPROGDIR%\brconnect -u / -c -f dbshut -f
if %USERNAME%=="SYSTEM" goto bad_user
tasklist | find "mmc.exe" > %LOGFILE%
if "0" == "%ERRORLEVEL%" taskkill /IM mmc.exe >> %LOGFILE%
echo %MYNTREGCMD%
%MYNTREGCMD%
call %MYSID%env.cmd
set /a MAXLOOPS=20
set /a LOOPS=0
:RESUME
set /a LOOPS=%LOOPS%+1
echo.
echo ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~###
echo Loop Nr.: %LOOPS%
set /a LOOPERR=0
sapcontrol -prot PIPE -nr %SYSNUM% -function StopSystem ALL >> %LOGFILE%
sapcontrol -prot PIPE -nr %SYSNUM% -function WaitforStopped 15 15 >> %LOGFILE%
sapcontrol -prot PIPE -nr %SYSNUM% -function GetProcessList >> %LOGFILE%
set /a RC=%ERRORLEVEL%
if "4" == "%RC%" set LOOPERR=0
if not "4" == "%RC%" set LOOPERR=1
if "0" == "%LOOPERR%" goto GO_ON
echo Waiting to stop...
if %LOOPS% GEQ %MAXLOOPS% goto CHKFAILED
if not "0" == "%LOOPERR%" goto RESUME
:CHKFAILED
echo.
echo Max. number of loops (%MAXLOOPS%) reached. Stop failed!
goto ENDE
:GO_ON
if not "%CSYSNUM%" == "%SYSNUM%" net stop SAP%MYSID%_%CSYSNUM% >> %LOGFILE%
net stop SAP%MYSID%_%SYSNUM% >> %LOGFILE%
echo Instance stopped, stopping DB!
echo %MYDBSTOPCMD%
%MYDBSTOPCMD%
goto ENDE
:bad_user
echo Please use SIDadm! >>\batcherr.err
:ENDE
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please refer to Assign Computer Shutdown Scripts
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.