Auto configuration du profile Thunderbird à l'ouverture de session

Pour les postes Windows en domaine, il est possible de configurer automatiquement le profile Thunderbird pour l'utilisateur lors de sa première ouverture de session sur un poste.

Voilà un petit script bat qu'il suffira d'exécuter en logo script. Dans le même répertoire que ce script (!! important !!), il faut mettre un fichier de configuration nommé conf.bat, et bien sûre l'adapter à vos besoins:

REM @echo off SET SRVNETBIOSNAME=sas SET IMAPSRV=sas.domain.tld SET IMAPPORT=993 SET SMTPSRV=%IMAPSRV% SET SMTPPORT=465 SET DOMAIN=domain.tld SET COMPANY="Ma Super Societe" SET SOGO=enabled
REM @echo off cd "%~dp0" call conf.bat REM On arrete la si TB n'est pas installe IF NOT EXIST "%ProgramFiles%\Mozilla Thunderbird\Thunderbird.exe" GOTO END REM Si TB a deja ete lance, on ne cree pas de nouveau profile REM mais on applique les parametres obligatoires IF EXIST "%APPDATA%\Thunderbird" GOTO MANDATORYCONFIG ECHO . ECHO Creation du profile Mozilla Thunderbird "%programfiles%\Mozilla Thunderbird\thunderbird.exe" -createprofile default ECHO Personalisation du profile Mozilla Thunderbird REM Recuperation du nom de l'utilisateur en cours for /f "Tokens=2*" %%m in ('net user %USERNAME% /domain ^| find "Nom complet"') do SET FULLNAME=%%n REM L'alias par défaut est prenom.nom REM Convertion en lowercase REM todo: lancer un unaccent SET EMAIL=%FULLNAME: =.% CALL :LoCase EMAIL REM recherche du nom de profile aleatoire cree for /f %%a in ('dir /b "%APPDATA%\Thunderbird\Profiles\*.default"') do SET TBPROFILE=%%a SET TBPREFS=%APPDATA%\Thunderbird\Profiles\%TBPROFILE%\prefs.js ECHO user_pref("mail.account.account1.identities", "id1"); >> "%TBPREFS%" ECHO user_pref("mail.account.account1.server", "server1");>> "%TBPREFS%" ECHO user_pref("mail.account.account2.server", "server2");>> "%TBPREFS%" ECHO user_pref("mail.accountmanager.accounts", "account1,account2");>> "%TBPREFS%" ECHO user_pref("mail.accountmanager.defaultaccount", "account1");>> "%TBPREFS%" ECHO user_pref("mail.accountmanager.localfoldersserver", "server2");>> "%TBPREFS%" ECHO user_pref("mail.append_preconfig_smtpservers.version", 2);>> "%TBPREFS%" ECHO user_pref("mail.attachment.store.version", 1);>> "%TBPREFS%" ECHO user_pref("mail.folder.views.version", 1);>> "%TBPREFS%" ECHO user_pref("mail.forward_message_mode", 0);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.archive_folder", "imap://%USERNAME%@%IMAPSRV%/Archives");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.doBcc", false);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.draft_folder", "imap://%USERNAME%@%IMAPSRV%/Drafts");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.drafts_folder_picker_mode", "1");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.encryptionpolicy", 0);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.fcc_folder", "imap://%USERNAME%@%IMAPSRV%/sent-mail");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.fcc_folder_picker_mode", "1");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.fullName", "%FULLNAME%");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.reply_on_top", 1);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.sig_on_fwd", true);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.sign_mail", false);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.smtpServer", "smtp1"); ECHO user_pref("mail.identity.id1.stationery_folder", "imap://%USERNAME%@%IMAPSRV%/Templates");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.tmpl_folder_picker_mode", "1");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.use_custom_prefs", true);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.useremail", "%EMAIL%@%DOMAIN%");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.valid", true);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.organization", "%COMPANY%");>> "%TBPREFS%" ECHO user_pref("mail.prompt_purge_threshhold", true);>> "%TBPREFS%" ECHO user_pref("mail.purge_threshhold", 10240);>> "%TBPREFS%" ECHO user_pref("mail.rights.version", 1);>> "%TBPREFS%" ECHO user_pref("mail.root.imap-rel", "[ProfD]ImapMail");>> "%TBPREFS%" ECHO user_pref("mail.root.none-rel", "[ProfD]Mail");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.ageLimit", 30);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.applyToFlaggedMessages", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.check_new_mail", true);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.cleanupBodies", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.daysToKeepBodies", 30);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.daysToKeepHdrs", 30);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.directory-rel", "[ProfD]ImapMail/%IMAPSRV%");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.downloadByDate", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.downloadUnreadOnly", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.hostname", "%IMAPSRV%");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.keepUnreadOnly", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.login_at_startup", true);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.max_cached_connections", 5);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.moveOnSpam", true);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.moveTargetMode", 1);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.name", "%EMAIL%@%DOMAIN%");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.namespace.personal", "\"\"");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.numHdrsToKeep", 2000);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.port", %IMAPPORT%);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.purgeSpamInterval", 90);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.socketType", 3);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.spamActionTargetAccount", "imap://%USERNAME%@%IMAPSRV%");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.spamActionTargetFolder", "imap://%USERNAME%@%IMAPSRV%/junkmail");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.timeout", 29);>> "%TBPREFS%" ECHO user_pref("mail.server.server1.type", "imap");>> "%TBPREFS%" ECHO user_pref("mail.server.server1.userName", "%USERNAME%");>> "%TBPREFS%" ECHO user_pref("mail.server.server2.ageLimit", 30);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.applyToFlaggedMessages", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.cleanupBodies", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.daysToKeepBodies", 30);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.daysToKeepHdrs", 30);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.directory-rel", "[ProfD]Mail/Local Folders");>> "%TBPREFS%" ECHO user_pref("mail.server.server2.downloadByDate", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.downloadUnreadOnly", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.hostname", "Local Folders");>> "%TBPREFS%" ECHO user_pref("mail.server.server2.keepUnreadOnly", false);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.name", "Dossiers locaux");>> "%TBPREFS%" ECHO user_pref("mail.server.server2.numHdrsToKeep", 2000);>> "%TBPREFS%" ECHO user_pref("mail.server.server2.spamActionTargetAccount", "mailbox://nobody@Local%20Folders");>> "%TBPREFS%" ECHO user_pref("mail.server.server2.spamActionTargetFolder", "mailbox://nobody@Local%20Folders/Junk");>> "%TBPREFS%" ECHO user_pref("mail.server.server2.type", "none");>> "%TBPREFS%" ECHO user_pref("mail.server.server2.userName", "nobody");>> "%TBPREFS%" ECHO user_pref("mail.smtpserver.smtp1.authMethod", 3);>> "%TBPREFS%" ECHO user_pref("mail.smtpserver.smtp1.hostname", "%SMTPSRV%");>> "%TBPREFS%" ECHO user_pref("mail.smtpserver.smtp1.port", %SMTPPORT%);>> "%TBPREFS%" ECHO user_pref("mail.smtpserver.smtp1.try_ssl", 3);>> "%TBPREFS%" ECHO user_pref("mail.smtpserver.smtp1.username", "%USERNAME%");>> "%TBPREFS%" ECHO user_pref("mail.smtpservers", "smtp1");>> "%TBPREFS%" ECHO user_pref("mail.spam.manualMark", true);>> "%TBPREFS%" ECHO user_pref("mail.spam.version", 1);>> "%TBPREFS%" ECHO user_pref("mail.startup.enabledMailCheckOnce", true);>> "%TBPREFS%" ECHO user_pref("mailnews.quotingPrefs.version", 1);>> "%TBPREFS%" ECHO user_pref("mailnews.tags.version", 2);>> "%TBPREFS%" ECHO user_pref("network.cookie.lifetimePolicy", 2);>> "%TBPREFS%" ECHO user_pref("network.cookie.prefsMigrated", true);>> "%TBPREFS%" ECHO user_pref("pref.privacy.disable_button.view_cookies", false);>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.sig_file", "%APPDATA%\\signature\\email.html");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.sig_file-rel", "[ProfD]../../../../signature/email.html");>> "%TBPREFS%" ECHO user_pref("mail.identity.id1.attach_signature", true);>> "%TBPREFS%" ECHO user_pref("mail.trusteddomains", "%DOMAIN%");>> "%TBPREFS%" ECHO . ECHO installation des certificats de securite XCOPY /I /Y "\\%NETBIOSSRV%\tools\certs\*.db" "%APPDATA%\Thunderbird\Profiles\%TBPROFILE%" ECHO . ECHO installation de l'integrateur SOGo if exist T:\sogo\sogo-integrator*sogo.xpi ( if not exist %APPDATA%\Thunderbird\Profiles\%TBPROFILE%\extensions\sogo-integrator@inverse.ca ( xcopy /I /Y \\%%NETBIOSSRV%\tools\sogo\*sogo.xpi "%APPDATA%\Thunderbird\Profiles\%TBPROFILE%\extensions\" ) ) :MANDATORYCONFIG ECHO . ECHO Copie des fichiers de signature if exist Z:\signature ( xcopy /E /I /Y \\%NETBIOSSRV%\home\signature "%USERPROFILE%\signature" ) ECHO . ECHO Application des parametres requis SET TBPREFS=%APPDATA%\Thunderbird\Profiles\default\%TBPROFILE%\user.js REM ECHO user_pref("ldap_2.autoComplete.directoryServer", "ldap_2.servers.mycompany");> "%TBPREFS%" REM ECHO user_pref("ldap_2.autoComplete.useDirectory", true);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.prefs_migrated", true);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.history.filename", "history.mab");>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.history.replication.lastChangeNumber", 0);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.mycompany.auth.savePassword", true);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.mycompany.description", "My Company");>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.mycompany.filename", "abook-1.mab");>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.mycompany.position", 3);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.mycompany.replication.lastChangeNumber", 0);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.mycompany.uri", "ldap://%IMAPSRV%:389/OU=Departments, DC=subdomain, DC=mycompany, DC=com??sub?(objectclass=User)");>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.pab.filename", "abook.mab");>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.pab.replication.lastChangeNumber", 0);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.user_directory_1.filename", "user_directory_1.mab");>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.user_directory_1.replication.lastChangeNumber", 0);>> "%TBPREFS%" REM ECHO user_pref("ldap_2.servers.user_directory_1.uri", "moz-abldapdirectory://user_directory_1.mab");>> "%TBPREFS%" REM ECHO user_pref("mail.inline_attachments", false);>> "%TBPREFS%" REM ECHO user_pref("mailnews.message_display.disable_remote_image", true); >> "%TBPREFS%" REM ECHO user_pref("network.proxy.autoconfig_url", "http://webcache/proxy.pac");>> "%TBPREFS%" REM ECHO user_pref("network.proxy.type", 2);>> "%TBPREFS%" :LoCase :: Subroutine to convert a variable VALUE to all lower case. :: The argument for this subroutine is the variable NAME. FOR %%i IN ("A=a" "B=b" "C=c" "D=d" "E=e" "é=e" "ê=e" "è=e" "F=f" "G=g" "H=h" "I=i" "J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r" "S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z") DO CALL SET "%1=%%%1:%%~i%%" GOTO:EOF :END exit