Copy specific folders for each user profile in C:\Documents and Settings

Posted on 2010-01-01
Last Modified: 2012-05-08
I am looking to create a script or batch for use during a PC replacement.
I would like the script to copy each user's profile root folder ie c:\documents and settings\"User1"...  But just the user profile root folder PLUS ONLY the following specific folders:
\FAVORITES... \DESKTOP... \Application Data\Microsoft\OUTLOOK... \MY DOCUMENTS

I don't care much about specific internet settings or application settings, etc.. Just want to copy their desktop stuff, favorites, My Documents and a few other things to a shared specific temporary location (Maybe a folder called the same as the machine name that I have already created) on a server so that I can easily copy the files back onto the new machine after they have logged on and created their new user profile.

So when the batch or script is done I would have on my server share:
........Favorites (Including all files/folders)
........Desktop (Including all files/folders)
........OUTLOOK (Including all files, or more specifically the .Nk2 files)
........My Documents (Including all files/folders)
........My Documents

This would be a huge time saver for us, and user frustrtion saver for them..
I tried the Files and Settings Transfer Wizard but it wasn't specific enough, and also looked at User State Migration Tool but seemed a little deep than what I am looking to do.
All machines are XP Pro SP3 on a domain environment.
Question by:riverhosp
    LVL 81

    Expert Comment

    Hello riverhosp,

    You don't mention Powershell but have a loot to the following :

    Powershell :

    Copy-Item -Container -recurse c:\documents and settings\*\favorites \\RHCH06\Migrations\PC-CNGH-01
    Copy-Item -Container -recurse c:\documents and settings\*\Desktop \\RHCH06\Migrations\PC-CNGH-01
    Copy-Item -Container -recurse c:\documents and settings\*\Application Data\Microsoft\OUTLOOK \\RHCH06\Migrations\PC-CNGH-01
    Copy-Item -Container -recurse c:\documents and settings\*\MY DOCUMENTS \\RHCH06\Migrations\PC-CNGH-01

    Open in new window

    LVL 51

    Expert Comment

    by:Bill Prew
    Here's a batch approach that should be pretty close to what you want.  I have commented out the XCOPY for now with an ECHO so you can test it and see what the XCOPY command that would be executed would look like without actually copying files.  When you are ready to use it just delete the word ECHO before the XCOPY command.

    @echo off
    setlocal EnableDelayedExpansion
    set BackupDir=\\RHCH06\Migrations
    set FolderList="favorites" "desktop" "application data\microsoft\outlook" "my documents"
    set BaseDir=c:\documents and settings
    set XcopyOptions=/e /i /q /h
    for /f "tokens=*" %%A in ('dir /ad /b "%BaseDir%"') do (
      for %%B in (%FolderList%) do (
        ECHO xcopy %XcopyOptions% "%BaseDir%\%%A\%%~B" "%BackupDir%\%COMPUTERNAME%\%%A\%%~B"

    Open in new window

    LVL 7

    Expert Comment

    can you try this
    cd "c:\Documents and setting"
    dir /b > temp.txt
    for /f %%x in ('type temp.txt') do (
    cp "c:\Documents and settings\%%x\\FAVORITES... \DESKTOP... \Application Data\Microsoft\OUTLOOK... \MY DOCUMENTS  <new location>

    Open in new window

    LVL 81

    Expert Comment

    Remotelly, from a remote PC or server, this will work too if you have suffisant credentials :

    correction previous script, add double quotes example : "c:\documents and settings\*\favorites"
    Copy-Item -Container -recurse "\\PC-CNGH-01\c$\documents and settings\*\favorites" \\RHCH06\Migrations\PC-CNGH-01
    Copy-Item -Container -recurse "\\PC-CNGH-01\c$\documents and settings\*\Desktop" \\RHCH06\Migrations\PC-CNGH-01
    Copy-Item -Container -recurse "\\PC-CNGH-01\c$\documents and settings\*\Application Data\Microsoft\OUTLOOK" \\RHCH06\Migrations\PC-CNGH-01
    Copy-Item -Container -recurse "\\PC-CNGH-01\c$\documents and settings\*\MY DOCUMENTS" \\RHCH06\Migrations\PC-CNGH-01

    Open in new window

    LVL 7

    Expert Comment

    a small change

    cd "c:\Documents and setting"
    dir /b > temp.txt

    for /f %%x in ('type temp.txt') do (
    cp "c:\Documents and settings\%%x\FAVORITES... \DESKTOP... \Application Data\Microsoft\OUTLOOK... \MY DOCUMENTS"  <new location>
    LVL 1

    Accepted Solution

    Thanx everyone for your input.. While I was waiting for replies, I did find an EE atricle that was asking the same thing, and the solution worked well..


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
    When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
    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…
    This video discusses moving either the default database or any database to a new volume.

    761 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

    13 Experts available now in Live!

    Get 1:1 Help Now