How to create batch script to copy folders over network?

Posted on 2007-10-19
Last Modified: 2008-01-09
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?
Question by:bemara57
    LVL 30

    Accepted Solution

    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
    LVL 51

    Assisted Solution

    I'd use xcopy instead ...

    Assisted Solution

    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.

    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 :
    its pretty accurate, or just type robocopy /? at cmd prompt.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now