Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Backup User Profile in BAT file

Avatar of pcgym
pcgymFlag for United States of America asked on
Microsoft DOSWindows XPWindows Batch
12 Comments1 Solution776 ViewsLast Modified:
I would like to add the "My Documents" folder to the list of files that are backed up in this script.

I would also like to back it up to a UNC path or mapped drive.

Can anyone help with this?
:: ========================================
:: BKUPUSER.BAT
::
:: Copy user data to C_BACKUP\%ComputerName% folder
:: ========================================
@echo off

:: ----------------------------------------
:: Initialise Variables
:: ----------------------------------------
set PstFolder=%userprofile%\Local Settings\Application Data\Microsoft\Outlook
set Nk2Folder=%userprofile%\Application Data\Microsoft\Outlook
set FavoritesFolder=%userprofile%\Favorites
set SignaturesFolder=%userprofile%\Application Data\Microsoft\Signatures
set BackupFolder=%userprofile%\My Documents\c_backup\%computername%

:: ----------------------------------------
:: Prepare Folders
:: ----------------------------------------
md "%BackupFolder%\pst" 2>nul
md "%BackupFolder%\nk2" 2>nul
md "%BackupFolder%\signatures" 2>nul
md "%BackupFolder%\favorites" 2>nul
 
:: ----------------------------------------
:: Copy PST Files
:: ----------------------------------------
echo Copying PST files....
xcopy "%PstFolder%\*.pst" "%BackupFolder%\pst\" /y /q /r >nul 2>&1
if %errorlevel%==4 (
   echo.
   echo You must close Outlook before backing up it's PST files....
   echo.
   pause
   exit /b 4
)
 
:: ----------------------------------------
:: Copy NK2 Files
:: ----------------------------------------
echo Copying NK2 files....
xcopy "%Nk2Folder%\*.nk2" "%BackupFolder%\nk2\" /y /q /r >nul
 
:: ----------------------------------------
:: Copy Favorites
:: ----------------------------------------
echo Copying Favourites....
xcopy "%FavoritesFolder%\*.*" "%BackupFolder%\Favorites\" /y /r /q /s /h 1>nul 2>errors.txt
 
:: ----------------------------------------
:: Copy Signatures
:: ----------------------------------------
echo Copying Outlook's signatures....
xcopy "%SignaturesFolder%\*.*" "%BackupFolder%\signatures\" /y /q /r >nul
ASKER CERTIFIED SOLUTION
Avatar of Rory de Leur
Rory de LeurFlag of Netherlands imageConsultant End-User Computing

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers