nmedovich Posted May 7, 2007 Share Posted May 7, 2007 (edited) @echo off:: variablesset drive=C:\Backupset backupcmd=xcopy /s /c /d /e /h /i /r /yecho ### Backing up My Documents...%backupcmd% "%USERPROFILE%\My Documents" "%drive%\My Documents"echo ### Backing up Favorites...%backupcmd% "%USERPROFILE%\Favorites" "%drive%\Favorites"echo ### Backing up email and address book (Outlook Express)...%backupcmd% "%USERPROFILE%\Application Data\Microsoft\Address Book" "%drive%\Address Book"%backupcmd% "%USERPROFILE%\Local Settings\Application Data\Identities" "%drive%\Outlook Express"echo ### Backing up email and contacts (MS Outlook)...%backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%\Outlook"echo ### Backing up the Registry...if not exist "%drive%\Registry" mkdir "%drive%\Registry"if exist "%drive%\Registry\regbackup.reg" del "%drive%\Registry\regbackup.reg"regedit /e "%drive%\Registry\regbackup.reg":: use below syntax to backup other directories...:: %backupcmd% "...source directory..." "%drive%\...destination dir..."echo Backup Complete!@pausecls%backupcmd% "%USERPROFILE%" "%drive%\%UserName% - profile"@pauseRate This PlzUsed in Windows Batch File .bat Edited May 7, 2007 by nmedovich Link to comment Share on other sites More sharing options...
Yzöwl Posted May 7, 2007 Share Posted May 7, 2007 The main problems are:You should be using SETLOCAL in order to ensure that variables are local only to the running batch file.Your XCOPY switches are not really very intelligently used.Other than that because there is little happening, there isn't much else to improve upon; there is no need to created FOR loops but you could tidy it slightly:@ECHO OFF&SETLOCALSET "L_=D:\Backup"SET "M_=Copying"SET "S_=%USERPROFILE%"SET "C_=XCOPY/DEIQRVY"SET "D_=My Documents"ECHO/ %M_% %D_%...%C_% "%S_%\%D_%" "%L_%\%D_%"SET "D_=Favorites"ECHO/ %M_% %D_%...%C_% "%S_%\%D_%" "%L_%\%D_%" Link to comment Share on other sites More sharing options...
nmedovich Posted May 8, 2007 Author Share Posted May 8, 2007 thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now