This code was used to speed up the setup of SyncToy 2.1 (I see no reason to backup the entire user profile folder, but I hate having to setup multiple sync jobs). As Microsoft has not updated SyncToy it may not work on anything other than Windows 7.
The script expects SyncToy 2.1 is installed and that the destination is always the H drive (For whatever reason I am not using a variable for the main location, I may update this at some point as code to select another path is already in).
rem Batch Script to setup Synctoy 2.1. Tested on Windows 7 for standard Users.
rem Additional Credits https://groups.google.com/forum/#!topic/alt.msdos.batch.nt/kOsN-QIOYEY for on the fly generation of VBS code
rem Amended 2/4/2014 to use Contribute instead of Synchronise to prevent unexpected deletions for users being moved servers with an out of date backup.
REM Check Windows Version is 7
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto sub_begincheck
goto sub_wrongos
:sub_begincheck
rem Show Home Drive for troubleshooting purposes
rem set homedrive
rem show profile directory for troubleshooting purposes
rem set userprofile
rem If Homedrive is H begin copy
if "%homedrive%"=="H:" then
Set backupdir=%homedrive%
goto :sub_synctoysetup
Else
rem If Homedrive is not H: ask for new filepath
goto :BrowseFolder
:sub_synctoysetup
rem Create Directories on H:
mkdir "H:\LaptopBackup\"
mkdir "H:\LaptopBackup\Desktop"
mkdir "H:\LaptopBackup\Favorites"
mkdir "H:\LaptopBackup\Documents"
mkdir "H:\LaptopBackup\Downloads"
mkdir "H:\LaptopBackup\Music"
mkdir "H:\LaptopBackup\Pictures"
mkdir "H:\LaptopBackup\Videos"
rem Change drive to C to action copy
C:
rem Change Directory to Synctoy
CD %ProgramFiles%\SyncToy 2.1
rem Setup SyncToy Folders for Windows 7
SyncToy.exe
SyncToy.exe -d(left="%USERPROFILE%\Desktop",right="H:\LaptopBackup\Desktop",name=Desktop,operation=Echo)
SyncToy.exe -d(left="%USERPROFILE%\Favorites",right="H:\LaptopBackup\Favorites",name=Favorites,operation=Echo)
SyncToy.exe -d(left="%USERPROFILE%\Documents",right="H:\LaptopBackup\Documents",name=Docs,operation=Echo)
SyncToy.exe -d(left="%USERPROFILE%\Downloads",right="H:\LaptopBackup\Downloads",name=Downloads,operation=Echo)
SyncToy.exe -d(left="%USERPROFILE%\Music",right="H:\LaptopBackup\Music",name=Music,operation=Echo)
SyncToy.exe -d(left="%USERPROFILE%\Pictures",right="H:\LaptopBackup\Pictures",name=Pictures,operation=Echo)
SyncToy.exe -d(left="%USERPROFILE%\Videos",right="H:\LaptopBackup\Videos",name=Videos,operation=Echo)
rem Clear Screen to make it easier to view next message
CLS
rem Copy Complete Echo and Pause
ECHO Setup of SyncToy is now Complete. Files are setup to be backed up to H:\LaptopBackup\. Please open SyncToy and run a backup now.
PAUSE
EXIT
:BrowseFolder
rem Set Temporary files
rem Below is the Visual Basic Script, do not indent!
set vbs=%temp%\_.vbs
set tmp=%temp%\_.cmd
> "%vbs%" echo set WshShell=WScript.CreateObject("WScript.Shell")
>>"%vbs%" echo set shell = WScript.CreateObject("Shell.Application")
>>"%vbs%" echo set folder=shell.BrowseForFolder(0,"Select Backup Location",0)
>>"%vbs%" echo if typename(folder)="Nothing" Then
>>"%vbs%" echo wscript.echo "set backupdir=Dialog Cancelled"
>>"%vbs%" echo WScript.Quit(1)
>>"%vbs%" echo end if
>>"%vbs%" echo set folderItems=folder.Items()
>>"%vbs%" echo set folderItem=folderItems.Item()
>>"%vbs%" echo pathname=folderItem.Path
>>"%vbs%" echo wscript.echo "set backupdir="^& chr(34) ^& pathname ^& chr(34)
rem Run the script with WSH
cscript //nologo "%vbs%" > "%tmp%"
rem Read the output file and set Path as Env variable %backupdir%
for /f "delims=" %%a in (%tmp%) do %%a
rem Clear up
DEL %VBS%
DEL %TMP%
rem Finished now go to copy
goto :sub_synctoysetup
:sub_wrongos
rem Wrong Operating System Detected, echo and exit
CLS
ECHO This script is only supported on Windows 7. You are running
ver
PAUSE
EXIT
:EOF
rem End of File Catch for Errors
ECHO End of file called!
PAUSE
EXIT