How do I backup from network drive( mapped) using batch file

Posted on 2006-05-10
Last Modified: 2010-07-27
I created a a batch file to backup my document to a thumb drive, which works fine.
@echo off
echo Backing up My Documents files
CD c:\Documents and Settings
CD user name
CD My Documents
xCOPY *.* e:\backup /e /y
echo Backup Complete

But when I move my document on a network & map it on my local drive & do necessary chages in the path in batch file it gives error. Is there any other command which is to be used for networked drive?
Question by:asify
    LVL 19

    Expert Comment

    by:Daniel Van Der Werken
    Try this:

    cd /d "c:\Documents and Settings"
    cd "user name"
    cd "my documents"
    xcopy /e /y *.* e:\backup
    cd \

    Author Comment

    It didn't work.

    Expert Comment

    Could you post your "modified" batch file and the error?
    LVL 2

    Expert Comment

    You should use the following command to manage network drive:

    ' REM Map drive Y as local
    net use Y: \\MyComputerName\MyDrive

    ' Write your own codes here e.g. cd "Y:\Documents and Setting" etc...

    ' REM Remove your mapping drive Y
    net use /d Y:

    LVL 19

    Accepted Solution

    Well, I assumed e: was already mapped.  If not:

    net use e: \\computername\share

    if the drive letter is in the path name (for example, c:\my documents versus \my documents), then you need the cd /d command line option instead of just cd.

    What's your error?

    Author Comment

     CD /d command worked. Thanks a lot. It was a great help!!

    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

    Join & Write a Comment

    Suggested Solutions

    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    This article will show, step by step, how to integrate R code into a R Sweave document
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    732 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

    19 Experts available now in Live!

    Get 1:1 Help Now