A script to copy the user profile from one PC to another PC / USB drive.
You must make sure you first logon / logoff the required user on the destination PC and then logon with a domain admin to run the script as it requires access to copy to a c$ share.
This script makes it much easier to copy user profiles between machines.
You must make sure you first logon / logoff the required user on the destination PC and then logon with a domain admin to run the script as it requires access to copy to a c$ share.
This script makes it much easier to copy user profiles between machines.
@ECHO OFF REM User Profile Copier Script REM REM REM Will copy Desktop items, Outlook PST files, REM Outlook NK2 (Auto-complete) files, Outlook REM Signatures, IE Favourites and anything in the REM the local My Documents folder TITLE User Profile Copier REM Change colour - because it's prettier and I'm a Leicester fan! color 1F cls echo. REM Get required details for profile copy set /p SourcePC=Please enter the Computer Name of the source PC or type 0 for this PC: echo. echo Please enter either the destination Computer Name or the destination set /p Destination=USB drive letter (eg. E:) To copy to the local PC type "C:" echo. REM Ascertain media set /p Media=Is this a USB or local C: (D)rive or is it a destination (P)C? echo. set /p user=Please enter the Username for the user you wish to copy: REM Set filename for copy log as profilecopy-USERNAME-DATE.txt set ProfFile=profilecopy-%user%-%date:~-11,2%%date:~-7,2%%date:~-2,2%.txt echo. TITLE User Profile Copier - %user% cls echo. REM Output message to CMD window echo The script is now running, please wait... REM Begin witing logfile, note initially everything is written to the root of the local c: drive echo Profile Copy > c:\%ProfFile% echo ---------------- >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Date: %date% >> c:\%ProfFile% echo Time: %time:~-11,5% >> c:\%ProfFile% echo. >> c:\%ProfFile% if /i %sourcepc% EQU 0 echo Source: %computername% >> c:\%ProfFile% if /i %sourcepc% NEQ 0 echo Source: %sourcepc% >> c:\%ProfFile% echo Destination: %destination% >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Username: %user% >> c:\%ProfFile% echo. >> c:\%ProfFile% REM If copying to USB / local disk set destination accordingly if /i %media% EQU D set dest=%destination%\Documents and Settings\%user% if /i %media% NEQ P goto CheckSource REM If copying to network PC set location accordingly set dest=\\%destination%\c$\documents and settings\%user% if not exist "%dest%" goto DestError :CheckSource echo Begin Copy >> c:\%ProfFile% echo ---------------- >> c:\%ProfFile% echo. >> c:\%ProfFile% REM If source is local PC run different routine if /i %sourcepc% EQU 0 goto NoSource REM Set source location as remote machine set source=\\%sourcepc%\c$\documents and settings\%user% echo Copying Outlook NK2 (Auto-complete files)... >> c:\%ProfFile% REM Copy Outlook NK2 files from source to destination xcopy "%source%\Application Data\Microsoft\Outlook\*.nk2" "%dest%\Application Data\Microsoft\Outlook\*.nk2" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% REM If there is an error with the copy goto an error routine if %ERRORLEVEL% EQU 1 goto DestError if %ERRORLEVEL% EQU 4 goto SourceError echo Copying desktop items... >> c:\%ProfFile% REM Copy desktop items from source to destination xcopy "%source%\Desktop\*" "%dest%\Desktop\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying Outlook PST files... >> c:\%ProfFile% REM Copy PST files from source to destination (only in folder Local Settings\App Data\Microsoft\Outlook\ xcopy "%source%\Local Settings\Application Data\Microsoft\Outlook\*.pst" "%dest%\Local Settings\Application Data\Microsoft\Outlook\*.pst" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying Outlook Signatures... >> c:\%ProfFile% REM Copy Outlook Signatures from source to destination xcopy "%source%\Application Data\Microsoft\Signatures\*" "%dest%\Application Data\Microsoft\Signatures\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying IE Favourites... >> c:\%ProfFile% REM Copy IE Favourites from source to destination xcopy "%source%\Favorites\*" "%dest%\Favorites\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying My Documents folder... >> c:\%ProfFile% REM Copy My Documents folder from source to destination if exist "%source%\My Documents" xcopy "%source%\My Documents\*" "%dest%\My Documents\*" /s /y >> c:\%ProfFile% if exist "%source%\%user%'s Documents" xcopy "%source%\%user%'s Documents" "%dest%\My Documents\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% goto Complete :NoSource REM Set source location as... set source=c:\documents and settings\%user% echo Copying Outlook NK2 (Auto-complete files)... >> c:\%ProfFile% REM Copy Outlook NK2 files from source to destination xcopy "%source%\Application Data\Microsoft\Outlook\*.nk2" "%dest%\Application Data\Microsoft\Outlook\*.nk2" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% REM If there is an error with the copy goto an error routine if %ERRORLEVEL% EQU 1 goto DestError if %ERRORLEVEL% EQU 4 goto SourceError echo Copying desktop items... >> c:\%ProfFile% REM Copy desktop items from source to destination xcopy "%source%\Desktop\*" "%dest%\Desktop\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying Outlook PST files... >> c:\%ProfFile% REM Copy PST files from source to destination (only in folder Local Settings\App Data\Microsoft\Outlook\ xcopy "%source%\Local Settings\Application Data\Microsoft\Outlook\*.pst" "%dest%\Local Settings\Application Data\Microsoft\Outlook\*.pst" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying Outlook Signatures... >> c:\%ProfFile% REM Copy Outlook Signatures from source to destination xcopy "%source%\Application Data\Microsoft\Signatures\*" "%dest%\Application Data\Microsoft\Signatures\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying IE Favourites... >> c:\%ProfFile% REM Copy IE Favourites from source to destination xcopy "%source%\Favorites\*" "%dest%\Favorites\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% echo Copying My Documents folder... >> c:\%ProfFile% REM Copy My Documents folder from source to destination if exist "%source%\My Documents" xcopy "%source%\My Documents\*" "%dest%\My Documents\*" /s /y >> c:\%ProfFile% if exist "%source%\%user%'s Documents" xcopy "%source%\%user%'s Documents" "%dest%\My Documents\*" /s /y >> c:\%ProfFile% echo. >> c:\%ProfFile% goto Complete :DestError REM DestError will trigger when there is an issue getting files to a destination PC cls echo Either the access rights are not set correctly or the user does not yet exist echo on the destination PC. echo Either the access rights are not set correctly or the user does not yet exist on the destination PC. >> c:\%ProfFile% echo. echo This script will now close. goto End :SourceError REM SourceError will trigger when there is an issue getting files from a source PC cls echo The source files cannot be found, please make sure the username and source echo computer name are correct. echo The source files cannot be found, please make sure the username and source computer name are correct. >> c:\%ProfFile% echo. echo This script will now close. goto End :Complete cls echo The script completed successfully, the files are now copied to: echo %dest%\ echo. >> c:\%ProfFile% echo The script completed successfully, the files are now copied to %dest%\ >> c:\%ProfFile% REM Move logfile to destination move /y c:\%ProfFile% "%dest%\%ProfFile%" :End REM If a copy errors out the logfile will remain on the root of the c: drive echo. pause