I have the following Batch file... When I run it in a normal command prompt - it runs as expected... Find that the server and destination exist, and does the backup and exits.
When I run this using the task scheduler - it sends the email that it cannot find the server, but still does the backup... Can anyone shed some light on this?
I'm running this on a Windows 7 machine.
:: Check for Network Connection...
ping <server> -n 1|find "Reply from"
if not errorlevel 0 goto NoNetwork
if not exist "\\<server>\SHARE\FOLDER" goto NoFolder
:: Do Stuff
robocopy "\\<server>\SHARE\FOLDER" "F:\Backups\<server>\FOLDER" *.* /E /SEC /COPYALL /PURGE /V /LOG:"c:\Logs\Backup.FILENAME.log" /ZB /R:5 /W:20 /TEE
goto end
:NoNetwork
Echo Network Not found...
c:\Utils\bmail.exe -s MAILSERVER -t MAIL_TO -f MAIL_FROM -h -a "ERROR: Network Not Found..." -b "FILENAME - <server> Not Found"
goto end
:NoFolder
Echo Folder Not found...
c:\Utils\bmail.exe -s MAILSERVER -t MAIL_TO -f MAIL_FROM -h -a "ERROR: Folder Not Found..." -b "FILENAME - Folder Not Found"
goto end
:end
exit