This script is run from windows task scheduler every X minutes (whatever you want to set it to). It looks for a running process, in this case Yokogawa FastTools rdcy.exe and if found checks for and deletes a file on disk named “skip”. If it doesn’t find rdcy.exe running it creates the “skip” file and then sends an email warning of the service failure using the very useful bmail

The script alerts once. You could probably rewrite this in VBS or Powershell for use in later operating systems but for quick and dirty alerting it works. This is running on an old Windows 2003 Server but would still work on Windows 2008 and 2012.

@echo off

REM +------------- CHECK BACKUP HAS COMPLETED ------------------------+
REM + 
REM + Name	Comment
REM + JMCD	2:08 PM 25/01/2010 Created
REM + JMCD      8:18 AM 3/09/2013 Modified for FT01
REM + JMCD	9:33 AM 8/11/2013 removed test for check file and 
REM +           check for rdcy.exe
REM + TOGGEN	12:38 PM 13/09/2017 changed SMTP Servers and send to 
REM +           TGN email address
REM +------------------------------------------------------------------+

set THIS_DIR=%~dp0
set BMAIL=%THIS_DIR%\bmail.exe

REM Set the hostname to use in the email
for /f "Usebackq" %%i IN (`hostname`) DO set HOSTNAME=%%i

tasklist | findstr rdcy.exe

if errorlevel 1 (

	if exist skip (
		echo Already notified skipping
		goto :EOF
	)
	
	echo %DATE% %TIME% > skip
	"%BMAIL%" -s 10.20.17.9 ^
	      -t james@toggen.com.au ^
	      -p 25 ^
	      -h ^
	      -f "%COMPUTERNAME%@customer_domain_example.com" ^
	      -b "%DATE% %TIME% Redundancy Failure on %HOSTNAME%" ^
	      -a "Services Redundancy Failure on %HOSTNAME%"
) else (
	if exist skip del skip
)