[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5786
  • Last Modified:

How to create batch script to copy folders over network?

I want to create a Windows batch script that will copy from one server to another over the network, but I don't know how I would authenticate with the batch script. Can someone please help with an example?
0
bemara57
Asked:
bemara57
3 Solutions
 
SteveGTRCommented:
You can do this using net use:

net use \\server\share password /user:domainname\user

Domainname is optional.

Then you could copy the file like so:

copy c:\temp\temp.txt \\server\share\dir
0
 
ahoffmannCommented:
I'd use xcopy instead ...
0
 
jeffpeterhuntCommented:
log in with an admin account onto a computer that has robocopy installed (part of windows resource kit).  Make sure that the account logged in with has permissions in both locations.
click start>run> type cmd and press enter.

type:
robocopy <source> <destination> /e /z

substituting \\<servername>\<share> for the "<source>" and "<destination>"

e.g. robocopy \\server01\share01 \\server02\share02 /e /z

the /e will copy all sub-directories including empty ones
the /z will copy the files in restartable mode

if you need more help, go here : http://en.wikipedia.org/wiki/Robocopy
its pretty accurate, or just type robocopy /? at cmd prompt.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now