107 lines
5.6 KiB
Batchfile
107 lines
5.6 KiB
Batchfile
@echo off
|
||
title Synczilla
|
||
REM ATTENTION, encodage OEM 850
|
||
|
||
SETLOCAL EnableDelayedExpansion
|
||
|
||
REM Check argument
|
||
if "%1" NEQ "login" if "%1" NEQ "logout" (
|
||
echo Aucun ou mauvais argument. Veuillez pr‚ciser login ou logout.
|
||
pause > nul
|
||
exit
|
||
)
|
||
|
||
REM CHECK APPS OUVERTES
|
||
:ffloop
|
||
timeout 1 >NUL
|
||
tasklist | findstr firefox.exe 1>NUL
|
||
if %errorlevel% EQU 0 (cls && echo Veuillez fermer Firefox et appuyer sur Entr‚e... && timeout 1>NUL && goto ffloop)
|
||
|
||
:thloop
|
||
timeout 1 >NUL
|
||
tasklist | findstr thunderbird.exe 1>NUL
|
||
if %errorlevel% EQU 0 (cls && echo Veuillez fermer Thunderbird et appuyer sur Entr‚e... && timeout 1>NUL && goto thloop)
|
||
|
||
:chloop
|
||
timeout 1 >NUL
|
||
tasklist | findstr chrome.exe 1>NUL
|
||
if %errorlevel% EQU 0 (cls && echo Veuillez fermer Chrome et appuyer sur Entr‚e... && timeout 1>NUL && goto chloop)
|
||
|
||
|
||
REM PARTIE RESTAURATION
|
||
if "%1" == "login" (
|
||
cls&&echo RESTAURATION......
|
||
if exist P: (
|
||
REM Check existance profil FF
|
||
if not exist %appdata%\Mozilla\Firefox (color 4f&&cls&&echo Aucun profil firefox trouv‚.&&echo Firefox n'est pas install‚, ou n'a jamais ‚t‚ lanc‚ dans cette session sur cet ordinateur.&&pause>nul&&exit)
|
||
REM R‚cup du nom du profil de destination
|
||
for /f "delims=/ tokens=2" %%a in ('type %appdata%\mozilla\firefox\profiles.ini ^| findstr Default^=Profiles') do set ffprofile=%%a
|
||
|
||
REM Restauration FF
|
||
copy /y P:\sync\ff-roaming\cert9.db %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
copy /y P:\sync\ff-roaming\cookies.sqlite %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
copy /y P:\sync\ff-roaming\key4.db %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
copy /y P:\sync\ff-roaming\permissions.sqlite %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
copy /y P:\sync\ff-roaming\places.sqlite %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
copy /y P:\sync\ff-roaming\favicons.sqlite %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
copy /y P:\sync\ff-roaming\webappsstore.sqlite %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
REM recup hostname dans variable pour le mettre dans le prefs.js
|
||
for /f %%a in ('hostname') do set hostname=%%a
|
||
type P:\sync\ff-roaming\prefs.js | findstr /v services.sync.client.name > %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\prefs.js
|
||
echo user_pref^("services.sync.client.name", "!hostname!"^); >> %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\prefs.js
|
||
if exist P:\sync\ff-roaming\extension-preferences.json copy /y P:\sync\ff-roaming\extension-preferences.json %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
if exist P:\sync\ff-roaming\extensions.json copy /y P:\sync\ff-roaming\extensions.json %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\
|
||
if exist P:\sync\ff-roaming\extensions robocopy P:\sync\ff-roaming\extensions %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\extensions /mir
|
||
|
||
REM Restauration TH
|
||
REM R‚cup nom profil en cours
|
||
if exist P:\sync\th-roaming (robocopy /np /mir /xo P:\sync\th-roaming %appdata%\Thunderbird && copy /y P:\sync\th-roaming\profiles.ini %appdata%\Mozilla\Thunderbird)
|
||
|
||
REM Restauration Chrome
|
||
if exist P:\sync\chrome (robocopy /np /mir /xo P:\sync\chrome %localappdata%\Google\Chrome)
|
||
)
|
||
)
|
||
|
||
REM PARTIE SAUVEGARDE
|
||
if "%1" == "logout" (
|
||
cls&&echo SAUVEGARDE.....
|
||
if exist P: (
|
||
REM Check existance profil FF
|
||
if not exist %appdata%\Mozilla\Firefox (color 4f&&cls&&echo Aucun profil firefox trouv‚.&&echo Firefox n'est pas install‚, ou n'a jamais ‚t‚ lanc‚ dans cette session sur cet ordinateur.&&pause>nul&&exit)
|
||
|
||
REM R‚cup du nom du profil en cours … sauvegarder
|
||
for /f "delims=/ tokens=2" %%b in ('type %appdata%\mozilla\firefox\profiles.ini ^| findstr Default^=Profiles') do set ffprofile=%%b
|
||
|
||
REM Sauvegarde FF
|
||
set /a sync=0
|
||
type %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\prefs.js | findstr services.sync > NUL
|
||
if !errorlevel!==0 set /a sync=1 else set /a sync=0
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\cert9.db P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\cookies.sqlite P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\key4.db P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\permissions.sqlite P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\places.sqlite P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\favicons.sqlite P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\webappsstore.sqlite P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\prefs.js P:\sync\ff-roaming\
|
||
|
||
if !sync!==0 (
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\extension-preferences.json P:\sync\ff-roaming\
|
||
copy /y %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\extensions.json P:\sync\ff-roaming\
|
||
robocopy %appdata%\Mozilla\Firefox\Profiles\!ffprofile!\extensions P:\sync\ff-roaming\extensions /mir
|
||
)
|
||
if !sync!==1 (
|
||
if exist P:\sync\ff-roaming\extension-preferences.json del /q P:\sync\ff-roaming\extension-preferences.json
|
||
if exist P:\sync\ff-roaming\extensions.json del /q P:\sync\ff-roaming\extensions.json
|
||
if exist P:\sync\ff-roaming\extensions rmdir /q /s P:\sync\ff-roaming\extensions
|
||
)
|
||
|
||
REM Sauvegarde TH
|
||
for /f "delims=/ tokens=2" %%a in ('type %appdata%\Thunderbird\profiles.ini ^| findstr "Path"') do set thprofile=%%a
|
||
if exist %appdata%\Thunderbird robocopy /np /mir /xo %appdata%\Thunderbird P:\sync\th-roaming /xd %appdata%\Thunderbird\Profiles\!thprofile!\Mail /xd %appdata%\Thunderbird\Profiles\!thprofile!\ImapMail
|
||
|
||
REM Sauvegarde Chrome
|
||
if exist %localappdata%\Google\Chrome robocopy /np /mir /xo %localappdata%\Google\Chrome P:\sync\chrome /xd "%localappdata%\Google\Chrome\User Data\Default\Cache" /xd "%localappdata%\Google\Chrome\User Data\Default\Code Cache"
|
||
)
|
||
)
|
||
|