Rewrite this batch file to select correct user in xcopy

Posted on 2007-08-09
Last Modified: 2008-01-09
I am trying to write a batch file that I can put on the Netlogon share on the server.  But it has to accomodate everyone's user profile.  The following works great for copying MyDocuments of the user: "scottv"

xcopy "C:\Documents and Settings\scottv.CENTRAL\My Documents\*.*" \\\public\ /c /f /h /d /y /o /s /e

However, I want to be rewrite this script so that it selects the CURRENT user, because it will be a shared file by all users on the server.  
Question by:al4629740
    LVL 22

    Expert Comment

    "C:\Documents and Settings\%username%\My Documents\*.*" \\\public\ /c /f /h /d /y /o /s /e

    That should do it for you.


    LVL 22

    Assisted Solution

    forgot the xcopy:

    xcopy "C:\Documents and Settings\%username%\My Documents\*.*" \\\public\ /c /f /h /d /y /o /s /e
    LVL 58

    Expert Comment

    xcopy "C:\Documents and Settings\%UserName%\My Documents\*.*" \\\public\ /c /f /h /d /y /o /s /e
    LVL 95

    Accepted Solution

    Sorry, those won't work for vista or installs that are non-standard.

    Instead, why don't you use %userprofile%?

    xcopy "%userprofile%\My Documents\*.*" "\\\public\" /c /f /h /d /y /o /s /e

    Or better still, why don't you use a combination of Document Redirection and Offline files?

    Author Comment

    How do you use document redirection?
    LVL 95

    Expert Comment

    by:Lee W, MVP

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
    If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 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