shoris
asked on
Script User Favorites to a New Profile
Can anyone help me with a script.
I'm migrating users and computer accounts and the only thing I want to migrate from a Users profile to their newly created profiles is their "Favorites"
WIndows XP Users moving to new Profile in WIndows XP
WIndows 7 Users moving to new profile in WIndows 7
Is there a vbs script or batch file that anyone knows how to do this?
Thank you.
I'm migrating users and computer accounts and the only thing I want to migrate from a Users profile to their newly created profiles is their "Favorites"
WIndows XP Users moving to new Profile in WIndows XP
WIndows 7 Users moving to new profile in WIndows 7
Is there a vbs script or batch file that anyone knows how to do this?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's a great script, however, I want to copy the profile to the server then re-copy it back to the workstation.
Reason: I am migrating computer accounts to another domain and we are not using the ADMT tool to migrate the profiles. We are creating a new profile and with the new profile all we want to do is copy the favorites over.
Reason: I am migrating computer accounts to another domain and we are not using the ADMT tool to migrate the profiles. We are creating a new profile and with the new profile all we want to do is copy the favorites over.
Hi, you could try this script to copy favorites from all user folders from the current computer to the server share. It will save the favorites from each user to the path you speciy, plus the computer name and username.
For example, if you specify:
strDestination = "\\server\share\FavoritesB ackup"
it will copy favorites for each user to
\\server\share\FavoritesBa ckup\<comp utername>\ <username> \Favorites
If you're happy with that, I can provide a script to restore those favorites, but you would need to manually type in the computer name that was the old computer of that user, and it would them back.
Alternatively, if your users only really use one computer, then we could take out the computer name altogether, and have the script run just for the currently logged on user, so you could back them up with one script for the current user, then restore them with another script for the current user.
Regards,
Rob.
For example, if you specify:
strDestination = "\\server\share\FavoritesB
it will copy favorites for each user to
\\server\share\FavoritesBa
strDestination = "\\server\share\FavoritesBackup"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
If Right(strDestination, 1) = "\" Then strDestination = Left(strDestination, Len(strDestination) - 1)
If objFSO.FolderExists("C:\Users") = True Then
For Each objFolder In objFSO.GetFolder("C:\Users").SubFolders
CopyFolder objFolder.Path & "\Favorites", strDestination
Next
ElseIf objFSO.FolderExists("C:\Documents and Settings") = True Then
For Each objFolder In objFSO.GetFolder("C:\Documents and Settings").SubFolders
CopyFolder objFolder.Path & "\Favorites", strDestination
Next
End If
Sub CopyFolder(strSource, strTarget)
strFavorites = strSource & "\Favorites"
If objFSO.FolderExists(strFavorites) = True Then
If objFSO.FolderExists(strTarget & "\" & objNetwork.ComputerName) = False Then objFSO.CreateFolder strTarget & "\" & objNetwork.ComputerName
If objFSO.FolderExists(strTarget & "\" & objNetwork.ComputerName & "\" & Mid(strSource, InStrRev(strSource, "\") + 1)) = False Then objFSO.CreateFolder strTarget & "\" & objNetwork.ComputerName & "\" & Mid(strSource, InStrRev(strSource, "\") + 1)
objFSO.CopyFolder strFavorites, strTarget & "\" & objNetwork.ComputerName & "\" & Mid(strSource, InStrRev(strSource, "\") + 1) & "\"
End If
End Sub
If you're happy with that, I can provide a script to restore those favorites, but you would need to manually type in the computer name that was the old computer of that user, and it would them back.
Alternatively, if your users only really use one computer, then we could take out the computer name altogether, and have the script run just for the currently logged on user, so you could back them up with one script for the current user, then restore them with another script for the current user.
Regards,
Rob.
ASKER
that would be awesome if you can provide a script to restore please.
Hi, sorry, the backup script was missing a little bit of code. This should backup:
and this should restore:
Regards,
Rob.
strDestination = "\\D5PYX82SRING\C$\Temp\Scripts\FavoritesBackup"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
If Right(strDestination, 1) = "\" Then strDestination = Left(strDestination, Len(strDestination) - 1)
If objFSO.FolderExists("C:\Users") = True Then
For Each objFolder In objFSO.GetFolder("C:\Users").SubFolders
'WScript.Echo "Copyping " & objFolder.Path & "\Favorites to " & strDestination
CopyFolder objFolder.Path, strDestination
Next
ElseIf objFSO.FolderExists("C:\Documents and Settings") = True Then
For Each objFolder In objFSO.GetFolder("C:\Documents and Settings").SubFolders
'WScript.Echo "Copyping " & objFolder.Path & "\Favorites to " & strDestination
CopyFolder objFolder.Path, strDestination
Next
End If
Sub CopyFolder(strSource, strTarget)
strFavorites = strSource & "\Favorites"
If objFSO.FolderExists(strFavorites) = True Then
If objFSO.FolderExists(strTarget & "\" & objNetwork.ComputerName) = False Then objFSO.CreateFolder strTarget & "\" & objNetwork.ComputerName
If objFSO.FolderExists(strTarget & "\" & objNetwork.ComputerName & "\" & Mid(strSource, InStrRev(strSource, "\") + 1)) = False Then objFSO.CreateFolder strTarget & "\" & objNetwork.ComputerName & "\" & Mid(strSource, InStrRev(strSource, "\") + 1)
WScript.Echo "Copying " & strFavorites & " to " & strTarget & "\" & objNetwork.ComputerName & "\" & Mid(strSource, InStrRev(strSource, "\") + 1) & "\"
On Error Resume Next
objFSO.CopyFolder strFavorites, strTarget & "\" & objNetwork.ComputerName & "\" & Mid(strSource, InStrRev(strSource, "\") + 1) & "\"
If Err.Number <> 0 Then
WScript.Echo "Error " & Err.Number & ": " & Err.Description
End If
Err.Clear
On Error GoTo 0
End If
End Sub
and this should restore:
strSource = "\\D5PYX82SRING\C$\Temp\Scripts\FavoritesBackup"
If Right(strSource, 1) = "\" Then strSource = Left(strSource, Len(strSource) - 1)
strSource = InputBox("Please enter the source computer folder to restore favorites from:", "Source Folder", strSource & "\<COMPUTERNAME>")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
If objFSO.FolderExists(strSource) = True Then
If objFSO.FolderExists("C:\Users") = True Then
For Each objFolder In objFSO.GetFolder(strSource).SubFolders
'WScript.Echo "Copyping " & objFolder.Path & "\Favorites to " & strDestination
CopyFolder objFolder.Path, "C:\Users"
Next
ElseIf objFSO.FolderExists("C:\Documents and Settings") = True Then
For Each objFolder In objFSO.GetFolder(strSource).SubFolders
'WScript.Echo "Copyping " & objFolder.Path & "\Favorites to " & strDestination
CopyFolder objFolder.Path, "C:\Documents and Settings"
Next
End If
Else
WScript.Echo "Cannot find source folder " & strSource
End If
Sub CopyFolder(strSource, strTarget)
strFavorites = strSource & "\Favorites"
strRestoreTo = strTarget & "\" & Mid(strSource, InStrRev(strSource, "\") + 1) & "\Favorites"
If objFSO.FolderExists(strFavorites) = True Then
If objFSO.FolderExists(strRestoreTo) = True Then
WScript.Echo "Copying " & strFavorites & " to " & strRestoreTo
On Error Resume Next
objFSO.CopyFolder strFavorites, strRestoreTo
If Err.Number <> 0 Then
WScript.Echo "Error " & Err.Number & ": " & Err.Description
End If
Err.Clear
On Error GoTo 0
Else
WScript.Echo "Destination folder " & strRestoreTo & " not found."
End If
Else
WScript.Echo "Source folder " & strFavorites & " not found."
End If
End Sub
Regards,
Rob.
ASKER
Thank you so much.
Regards,
Rob.