RestoProfilManuel.vbs
Script permettant de restaurer les éléments du profil utilisateur connecté (Bureau, Documents, Favoris, Téléchargements, Images, profil Firefox, signatures Outlook).
'*************************************************
'RestoProfilManuel.vbs
'*************************************************
'Script permettant de restaurer les éléments
'du profil utilisateur connecté
'*************************************************
'Creation : LPR pour Carsat Rennes
'*************************************************
'v1.0 : Le 07/12/2021
'*************************************************
'*************************************************
'Déclaration des variables
'*************************************************
Dim oShell
Dim strAPPDATA, strUserProfile, strDesktop, strDocuments
Dim strTelechargement, strFavoris, strFirefox, strIniFirefox, strImages
Dim strSource, strRepFirefox, strCmd, strCmd2, strCmd3
Dim TabCommande(5)
Set oShell = CreateObject("WScript.Shell")
Set objApp = CreateObject("shell.application")
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1, ForWriting = 2
strUserName = oShell.ExpandEnvironmentStrings("%USERNAME%") 'Pour le login du user
strAPPDATA = oShell.ExpandEnvironmentStrings("%APPDATA%")
strUserProfile = oShell.ExpandEnvironmentStrings("%USERPROFILE%")
strDesktop = oShell.SpecialFolders("Desktop")
strDocuments = oShell.SpecialFolders("MyDocuments")
strTelechargement = strUserProfile & "\Downloads"
strFavoris = strUserProfile & "\Favorites"
strImages = strUserProfile & "\Pictures"
strFirefox = strAPPDATA & "\Mozilla\Firefox"
strOutlook = strAPPDATA & "\Microsoft\Signatures"
strSource = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
strSource = strSource & strUserName & "\"
'On minimize toutes les fenetres
objApp.MinimizeAll
'*************************************************
'Création d'un tableau pour les commandes
'*************************************************
TabCommande(0) = "robocopy.exe """ & strSource & "Bureau"" """ & strDesktop & """ /S "
TabCommande(1) = "robocopy.exe """ & strSource & "Documents"" """ & strDocuments & """ /MIR"
TabCommande(2) = "robocopy.exe """ & strSource & "Favoris"" """ & strFavoris & """ /MIR"
TabCommande(3) = "robocopy.exe """ & strSource & "Telechargements"" """ & strTelechargement & """ /MIR"
TabCommande(4) = "robocopy.exe """ & strSource & "Images"" """ & strImages & """ /MIR"
'*************************************************
'Restauration des répertoires
'*************************************************
For i = 0 to 4
oShell.Run TabCommande(i),1,True
Next
'*************************************************
'Restauration du profil Firefox
'*************************************************
strRepFirefox = strFirefox & "\Profiles"
strIniFirefox = strSource & "\Firefox\profiles.ini"
strCmd = "robocopy.exe """ & strSource & "Firefox\Profiles"" """ & strRepFirefox & """ /MIR"
strCmd2 = "xcopy.exe """ & strIniFirefox & """ """ & strFirefox & """ /Y"
oShell.Run strCmd,1,True
oShell.Run strCmd2,1,True
'*************************************************
'Sauvegarde des signatures Outlook
'*************************************************
strCmd3 = "robocopy.exe """ & strSource & "Outlook"" """ & strOutlook & """ /MIR"
oShell.Run strCmd3,1,True
msgbox "Restauration de " & strUserName & " terminée.",64,"Message"
Set oShell = Nothing
Set fso = Nothing
Set objApp = nothing
wscript.quit