Batch to copy and replace a txt file from one server to another

Posted by Sunny on Stack Overflow See other posts from Stack Overflow or by Sunny
Published on 2013-10-21T03:22:37Z Indexed on 2013/10/21 3:54 UTC
Read the original article Hit count: 164

Filed under:
|
|

I have two servers, server1 and server2 on same network but require username and password to be mapped. server1 has a text file as C:\Users\output.txt. I want to create and schedule a batch script on server1, which should copy and replace output.txt file from server1 to server2 at path E:\data\output.txt on daily basis. I don't want to map server2 manually every time I start my computer nor do I want to enter my username and password each time.

I am using following commands in a batch, but not working;

net use C: \\server2\E:\data server2password /user:server2domain\server2username /savecred /p:yes
xcopy C:\Users\output.txt E:\data\

© Stack Overflow or respective owner

Related posts about batch-file

Related posts about xcopy