• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1197
  • Last Modified:

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

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.
1 Solution
Hello riverhosp,

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

Powershell : http://www.microsoft.com/downloads/details.aspx?familyid=60deac2b-975b-41e6-9fa0-c2fd6aa6bc89&displaylang=en

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

Bill PrewCommented:
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

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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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

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>
riverhospAuthor Commented:
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..


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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