Welcome! Log In


simple script ... using sendmail exe http://caspian.dotconf.net/menu/Software/SendEmail/#download



set PATHTOOLS=D:\CHECK\

set service-name1=SQL Server Agent (SQL2012)
set service-name1min=SQLAgent$SQL2012
set service-name2=Simple Mail Transfer Protocol (SMTP)
set service-name2min=smtpsvc

Echo "My server IP with SMTP"

set ipservicesmtp=8.8.8.8

set tomail=myadresse@domain.com
set frommail=frommail@domain.com


cd %PATHTOOLS%
%PATHTOOLS%

echo 1

net start | find "%service-name1%" > nul 2>&1
if not .%errorlevel%.==.0. goto startservice
goto skip
:startservice
net start %service-namemin1%
echo service restarts %service-name1% @ %date% %time% >> %PATHTOOLS%results.txt
sendEmail.exe -f %frommail% -t %tomail% -s %ipservicesmtp% -u "%COMPUTERNAME% - %service-name1% ETAIT ARRETE %date% %time%" -m .
:skip
echo service ok %service-name1% @ %date% %time% >> %PATHTOOLS%results.txt


echo 2

net start | find "%service-name2%" > nul 2>&1
if not .%errorlevel%.==.0. goto startservice
goto skip
:startservice
net start %service-namemin2%
echo service restarts %service-name1% @ %date% %time% >> %PATHTOOLS%results.txt
sendEmail.exe -f %frommail% -t %tomail% -s %ipservicesmtp% -u "%COMPUTERNAME% - %service-name2% ETAIT ARRETE %date% %time%" -m .
:skip
echo service ok %service-name1% @ %date% %time% >> %PATHTOOLS%results.txt



Edited 1 time(s). Last edit at 10/06/2017 04:05PM by iznogoud.
Sorry, only registered users may post in this forum.

Click here to login