开发者

Problem with Batch File

开发者 https://www.devze.com 2022-12-17 19:56 出处:网络
I have the following Batch file... When I run it in a normal c开发者_JS百科ommand prompt - it runs as expected... Find that the server and destination exist, and does the backup and exits.

I have the following Batch file... When I run it in a normal c开发者_JS百科ommand 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


As to why the batch file might think the share is unavailable but robocopy can access it, perhaps robocopy has been configured with credentials for accessing that network share or at least a local user account, whereas the task scheduler is running under a different account?

As to why the call to robocopy would ever get made in this script... well, I have no idea.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号