Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '****************************************************************************
- '* Script for restoring a users 'Favourites' file for Internet Explorer *
- '****************************************************************************
- Option Explicit
- Dim user_name ' The user name of the currently logged in user
- Dim objNetwork ' The network
- Dim objFSO ' The File System Object
- Dim i, j ' Dummies for looping
- Set objNetwork = CreateObject("WScript.Network") ' Create the network object (used for getting the username)
- Set objFSO = CreateObject("Scripting.FileSystemObject")' Create the FSO object
- user_name = objNetwork.UserName
- Dim servers(3) ' The terminal servers to action
- Dim old_favourites_file_path ' The file path on a server of the old favourites file for individuals
- Dim old_favourites_unc ' The full UNC path to check for an old favourites file
- Dim new_profile_file_path ' The file path on a server of the new profile for individuals
- Dim new_profile_unc ' The full UNC path to check for the exsistnece of
- Dim new_favourites_file_path ' The file path on a server of the new favourites file for individuals
- Dim new_favourites_unc ' The full UNC path to copy the favourites file to
- Dim server_copy_list ' A list of the servers that a users favourites have been copied to
- Dim server_copy_count ' A count of the servers that have had favourites copied to them
- Dim not_copied_to_all ' The text string to display if the favourites are not copied to all servers
- servers(0) = "ttsa"
- servers(1) = "ttsb"
- servers(2) = "ttsc"
- servers(3) = "ttsd"
- old_favourites_file_path = "\d$\__OLD-PROFILES\" & user_name & "\Favorites\"
- new_profile_file_path = "\d$\Documents and Settings\" & user_name & "\"
- new_favourites_file_path = "\d$\Documents and Settings\" & user_name & "\Favorites\"
- server_copy_count = 0
- ' For each server, copy the users old favourites (if possible)
- for i = 0 to UBound(servers) step 1
- ' Set the UNC paths
- old_favourites_unc = "\\" & servers(i) & old_favourites_file_path
- new_profile_unc = "\\" & servers(i) & new_profile_file_path
- new_favourites_unc = "\\" & servers(i) & new_favourites_file_path
- ' Check to see if an old version of the favourites folder exists, and copy it if it does
- if objFSO.FolderExists(old_favourites_unc) then
- ' Check to see if a new profile on this server exists, if not, no log on to that server has yet occured, so the favourites will not be copied
- if objFSO.FolderExists(new_profile_unc) then
- ' Check that the favourites folder exists and create it if id does not
- if not objFSO.FolderExists(new_favourites_unc) then
- objFSO.CreateFolder(new_favourites_unc)
- end if
- ' Update the server copy list and the count of servers updated
- server_copy_list = server_copy_list & servers(i) & VBCr
- server_copy_count = server_copy_count + 1
- ' Do the magic and copy the favourites
- objFSO.CopyFolder old_favourites_unc & "\*.*", new_favourites_unc, true
- end if
- end if
- next
- ' Output a message to the user to confirm that their favourites have been copied
- if server_copy_count <> 4 then
- not_copied_to_all = VBCr & "Although your favourites could not be copied to all servers" & VBCr _
- & "(because you have not logged on to all of them), they will be copied" & VBCr _
- & "the next time you log on."
- end if
- Wscript.Echo "Your Internet Explorer Favourites have been copied to the" & VBCr _
- & "following servers -" & VBCr & VBCr & server_copy_list _
- & not_copied_to_all
- '****************************************************
- '* Reset the objects and exit *
- '****************************************************
- set objNetwork = nothing
- set objFSO = nothing
- WScript.Quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement