I have a batch script I'm using for a shut down procedure but recently had to add a section to check for hung processes. However, When I want to write any ECHO's in that section to my %logfile%, it wont.
The section labeled Check for Hung ESSSVR Processes at %TIME% is where my echo's wont write to log files. Any help is greatly appreciated, thanks!!
Code: Select all
REM --Call Environment Script--
call C:\Hyperion_Batch\Scripts\batch\_env.cmd
REM --Set working directory as script path--
cd /d %~dp0
REM ------------------------------------------------------------------------
REM SET LOG & ERROR PATHS
REM ------------------------------------------------------------------------
SET intrapath=%MAINPATH%%LOGPATH%%EPMSERVICESLOGS%
SET errorintrapath=%MAINPATH%%ERRORPATH%%EPMSERVICESLOGS%
FOR /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set timestamp=%%a%%b)
FOR /f "tokens=* delims= " %%c in ("%timestamp%") do (set timestamp=%%c)
REM ------------------------------------------------------------------------
REM SET & DELETE LOG FILES
REM ------------------------------------------------------------------------
SET logfile=%intrapath%%date:~-4,4%%date:~-10,2%%date:~-7,2%_%timestamp%_%~n0.log
SET errorfile=%errorintrapath%%date:~-4,4%%date:~-10,2%%date:~-7,2%_%timestamp%_%~n0.log
if exist %logfile% del %logfile%
if exist %errorfile% del %errorfile%
REM -- Invoke DRM Batch Client
echo ********************************************************>>%logfile%
echo %~n0 at %TIME% >>%logfile%
echo ********************************************************>>%logfile%
echo ********************************************************>>%logfile%
echo STOP ALL EPM SERVICES %TIME% >>%logfile%
echo ********************************************************>>%logfile%
REM Call %STOPEPMSYSTEM%
SET myError1=%errorlevel%
IF %myError1%==0 goto Stop_DRM_Service
echo ********************************************************>>%logfile%
echo Error Encountered in STOP ALL EPM SERVICES >>%logfile%
echo ********************************************************>>%logfile%
goto AbnormalExit
:Stop_DRM_Service
echo ********************************************************>>%logfile%
echo STOP DRM SERVICE %TIME% >>%logfile%
echo ********************************************************>>%logfile%
REM Call %STOPDRMSERVICE%
SET myError2=%errorlevel%
IF %myError2%==0 goto Check_ESSSVR
echo ********************************************************>>%logfile%
echo Error Encountered in STOP DRM SERVICE >>%logfile%
echo ********************************************************>>%logfile%
goto AbnormalExit
:Check_ESSSVR
echo ********************************************************>>%logfile%
echo Check for hung ESSSVR Processes %TIME% >>%logfile%
echo ********************************************************>>%logfile%
setlocal
tasklist /fi "imagename eq ESSSVR.exe" | find /i "ESSSVR.exe" > nul
if errorlevel 1 (
set ProcExists=NO
) else (
set ProcExists=YES
)
if /i "%ProcExists%"=="YES" (
%PSKILL% /t "ESSSVR.exe"
) else (
goto :ESSSVR_Not_Running
)
goto ESSSVR_Running
:ESSSVR_Not_Running
echo ********************************************************>>%logfile%
echo ESSSVR.exe WAS NOT RUNNING at %TIME% >>%logfile%
echo ********************************************************>>%logfile%
goto NormalExit
PAUSE
:ESSSVR_Running
echo ********************************************************>>%logfile%
echo ESSSVR.exe WAS TERMINATED at %TIME% >>%logfile%
echo ********************************************************>>%logfile%
goto NormalExit
PAUSE