0

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\
Sunny
  • 7,812
  • 10
  • 34
  • 48

1 Answers1

3

If the data folder is shared then you specify it like this:

\\server2\data

In your net use command you will usually have to pick a drive letter that is not in use, as C: is commonly already the system drive.

So something like this may work - if the other switches in the net use command are correct.

net use z: \\server2\data server2password /user:server2domain\server2username /savecred /p:yes
xcopy "C:\Users\output.txt" z:\
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • @Foxi..yeah.Its working like a charm now..!:) but its asking me to:`Overwrite z:\output.txt (Yes/No/All) ?` when second time this scheduled script runs..I want to make it `Yes` for forever..what code i need to insert above,,? – Sunny Oct 21 '13 at 13:27
  • 1
    xcopy /y "C:\Users\output.txt" z:\ <-- the `/y` should do it. Type this and read the help `XCOPY /?` – foxidrive Oct 21 '13 at 14:17