I have created a batch script which backups all local Windows user profiles to a local location (like USB disk).
I would like to add a menu when launching the script with 2 possibilities:
- Save a profile of your choice
- Save all profiles
Enter your choice:
By selecting choice 1, we would obtain this:
Enter the name of the profile to backup:
And the profile entered would be stored in a variable which would be interpreted by the argument / SOURCEUSERSPROFILESNAMES of my backup software (AutoBackup.exe).
By selecting choice 2, the operation would be similar to my current script:
@echo off
cls
SETLOCAL ENABLEDELAYEDEXPANSION
set BackupDest=%~dp0data
set BkpFolder=Bkp2_%computername%_%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%
set bin=%~dp0bin
set log=%~dp0logs
set cecho="%bin%\cecho\%PROCESSOR_ARCHITECTURE%\cecho.exe"
rem getting profiles
for /f "delims=" %%I in ('dir /a:d-h /b "%SystemDrive%\Users\*" 2^>nul ^| %SystemRoot%\System32\findstr.exe /i /l /x /v /g:"%bin%\exclude_users.txt"') do (
%cecho% {0c} ----------------------------------------------{\n}
%cecho% {0b} Backup of profile: %%~I{\n}
%cecho% {0c} ----------------------------------------------{\n}
%cecho% {0D}
rem starting the backup
"%bin%\AutoBackup.exe" /BACKUP /TO="%BackupDest%" /SUBFOLDER="%BkpFolder%" /SOURCEUSERSPROFILESNAMES="%%~I" /ALWAYSKEEPBOTH /DESKTOP /MYDOCUMENTS /MYPICTURES /IEFAVORITES /IESTARTPAGE /IESETTINGS /FIREFOX /OUTLOOKPST /OUTLOOKSIGNATURES /OUTLOOKNK2 /TEMPLATES /EXCLUSIONS="*.ost;*.exe;*.mp3;*.avi;*.mp4;*.mkv;*.iso" /LOGSTORAGE="%log%\%%~nI_%computername%\"
rem shortcut creation for restoration
if exist "%BackupDest%\%BkpFolder%\%%~I\*" (
echo Creating the shortcut "restore_user_profile"
"%bin%\shortcut.exe" /F:"%BackupDest%\%BkpFolder%\restore_user_profile.lnk" /A:C /T:%SystemRoot%\System32\cmd.exe /P:"/c start """""" """..\..\bin\AutoBackup.exe""" /SAVELOGLEVEL=0 /LOADCONF="""%%CD:~0,2%%%~p0data\%BkpFolder%\Backup.conf"" >nul
)
)
%cecho% {0c} --------------------------------------------------------------{\n silver}
pause
exit
I would like help to set up such a selective menu.
Thank you.
Aucun commentaire:
Enregistrer un commentaire