Example 1
--- Script start ---
if not exist c:\Logs md c:\Logs
net use \\sourceserver\robocopy /user:username password 1>c:\Logs\test.txt 2>&1
net use \\sourceserver\robocopy /user:username password 1>c:\Logs\test.txt 2>&1
--- Script end ---
"1>c:\Logs\test.txt 2>&1"
"1>" To capture error output; specify a full path for the log file. If not it might end up in the System32 folder.
"2>" = re-direction in DOS Command Prompt (console)
Example 2
--- Script start ---
net use \\sourceserver\robocopy /user:username password 1> c:\output.txt 2> c:\error.txt
dir \\sourceserver\robocopy 1>> c:\output.txt 2>> c:\error.txt
dir \\sourceserver\robocopy 1>> c:\output.txt 2>> c:\error.txt
--- Script end ---
Or to use one single log file:
--- Script start ---
net use \\sourceserver\robocopy /user:username password 1> c:\output.txt 2>&1
dir \\sourceserver\robocopy 1>> c:\output.txt 2>>&1
dir \\sourceserver\robocopy 1>> c:\output.txt 2>>&1
--- Script end ---
References:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/b591346e-3ed0-4ed1-9453-24851ebe1bb1
References:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/b591346e-3ed0-4ed1-9453-24851ebe1bb1