Skip to main content

Posts

Showing posts from January, 2020

Script to restart SMTP Service after the Inetpub folder size increases to a certain number

Hi Guys, Today I am going to give you a script which can be set in the scheduled tasks and made to run every 1 Hrs or as per your wish. Once this script runs it will check the 4 folders in Mailroot and see if its reached the limit (10) which you have set in the script and restarts the SMTP service.     This will prevent the SMTP service hung and many problems which are associated with SMTP server. The script is given below Copy it in notepad and save it as .bat extension so that it becomes a batch script. @echo off setlocal set /a count=0 for /f %%i in ('dir E:\Inetpub\mailroot\Badmail  ^| findstr /i /c:"file(s)"') do set count=%%i echo count=%count% if %count% GTR 10 (         net stop smtpsvc & net start smtpsvc     ) endlocal for /f %%i in ('dir C:\Inetpub\mailroot\Drop  ^| findstr /i /c:"file(s)"') do set count=%%i echo count=%count% if %count% GTR 10 (         net stop smtpsvc & net start smtpsvc     ) endlocal