move a file from one server to another server using a batch file

Can anyone tell me how to move a file from one server to another server using a batch file?  I can move a file within the same server, but not able to move it to another server.
moni81011Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AnuroopsunddCommented:
just to simplify .. you can map the shared folder of 2nd server in your batch file then copy the file as you are doing it locally. after copy completed delete the shared folder drive

net use x: \\servername\sharename  password /USER:myAccount
copy c:\text.txt x:\
net use x: /delete
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewCommented:
What have you tried that didn't work, and what was the error(s)?

~bp
0
moni81011Author Commented:
Could we do it the other way around?  Could we place this .bat file on the server the file is going to and grab the file from the server it is coming from?

Thanks in advance.
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

moni81011Author Commented:
What Anuroopsundd told me to do works, but I'm not exactly sure how to place the .bat file on our host as that is where the file resides.  So I wanted to see if there is a way to place the .bat file on the server the file is supposed to go to and what code needs to be changed in the .bat file.
0
Bill PrewCommented:
Should work the same way, just reverse the parms in the COPY, like:

net use x: \\servername\sharename  password /USER:myAccount
copy x:\text.txt c:\destdir
net use x: /delete

~bp
0
moni81011Author Commented:
I'm not 100% sure how to make that work.  Ok, this is what I did the first time to make it work:

I got a file from my pc and placed it on the server using what Anuroopsundd provided like this:

net use x: \\servername\sharename path (2nd server-destination server)
copy C:\Users\path\filename x:\
net use x: /delete

and that works.

Now I want to be able to put the .bat file on the second server where the file should end up at and tell it to go to the host and grab this file and put it on this server.
If I just reverse the second line where it is copying the information, it is looking for the file on the second server, which it will never find cause it resides on the first server.
Do I make any sense? I hope I do.  :)
0
Bill PrewCommented:
In the BAT file you put on the 2nd server, you will still specify the path from the first server in the line:

net use x: \\servername\sharename path

~bp
0
moni81011Author Commented:
Thank you.  I tried that, but for some reason it does not work.  
Thank you for all your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.