batch file sends email when zipping fails

October 27, 2014 at 02:34:08
Specs: Windows XP
please check the code and suggest any changes to be done.... i am successfully able to zip the logs and delete them as well but when i delete the zip file i dsnt get the backup in my mail id....

@echo off

rem Findout Month, Year and Date
FOR /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do set year=%%D
FOR /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do set month=%%B
FOR /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do set day=%%C

rem Solve problem Year start and adding 0 in month
if %month% EQU 01 (
set month=12
set /a year=%year%-1
) else (
set /a month=%month%-1
if %month% LSS 10 set month=0%month%

rem Set file names for last month file.
set lastmonthfiles=server.log.%year%-%month%-

rem To compress the file.
"C:\Program Files\7-Zip\7z.exe" a -y "" %lastmonthfiles%*
ping -n 15 > nul
if Not exist (
echo zipping failed
set ip=set ip=
for %%i in (%ip%) do (
ping -n 2 %%i > nul
if errorlevel 1 (
set msg=Ping failed: %%i
blat -to -subject %%Zip%%

DEL %lastmonthfiles%*


See More: batch file sends email when zipping fails

Report •

March 15, 2015 at 21:11:54
Have you tried sending something small just to see if blat is working on port 25. Sometimes 25 is blocked by ISP.


Report •
Related Solutions

Ask Question