VB Script to move IE favorites.

I have redirected IE favorites using a custom Group Policy template for users ion a Terminal Server to a Users share on the network . Example \\servername\Users\%username%\Favorites
 I need a VB Script that will move the favorites themselves from the old location to the new location.
The old location would look something like the following.
C:\Documents and Settings\Username\ Favorites
This would have to be done for approximately 100 users

Thanks in advance,
Bret
ziplizzardAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yehudahaCommented:
change the destination path in this line:

don't touch strUser

strDest = "\\servername\Users\" & strUser & "\Favorites"
Set objnet = CreateObject("WScript.Network")
Set objfso = CreateObject("Scripting.FileSystemObject")
strUser = objnet.UserName
strSource = "C:\Documents and Settings\" & strUser & "\Favorites"
strDest = "\\servername\Users\" & strUser & "\Favorites"
 
Set objFolder = objFSO.GetFolder(strSource)
 
Set colFiles = objFolder.Files
 
For Each objFile in colFiles
        objFSO.MoveFile objFile.Path, strDest
Next

Open in new window

0
ziplizzardAuthor Commented:
When the user runs this script they receive an error stating that the destination folder already exists. Because when the user logs in the Group Policy creates the new folder in the new location.
How can I move only the files?
0
yehudahaCommented:
change this:
strDest = "\\servername\Users\" & strUser & "\Favorites"

to this:
strDest = "\\servername\Users\" & strUser & "\Favorites\"
0
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

yehudahaCommented:
notice to the "\" at the end
0
ziplizzardAuthor Commented:
Same error.
0
ziplizzardAuthor Commented:
A copy might work rather than a move, but how do you copy items in subfolders as well?
0
yehudahaCommented:
what is the exact error ?
0
ziplizzardAuthor Commented:
Error: File already Exists
error.jpg
0
yehudahaCommented:
try this:

and please notice you must put "\" at the end

strDest = "\\servername\Users\" & strUser & "\Favorites\"
Set objnet = CreateObject("WScript.Network")
Set objfso = CreateObject("Scripting.FileSystemObject")
strUser = objnet.UserName
strSource = "C:\Documents and Settings\" & strUser & "\Favorites"
strDest = "\\servername\Users\" & strUser & "\Favorites\"
 
Set objFolder = objFSO.GetFolder(strSource)
 
Set colFiles = objFolder.Files
 
For Each objFile in colFiles
        objFSO.MoveFile objFile.Path, strDest
Next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ziplizzardAuthor Commented:
I am getting the same error.
0
ziplizzardAuthor Commented:
I think that by default Windows creates a sub folder in the favorites named "links" if this folder is there will it overwrite the existing file or ignore it by default? is it possible that this is causing the error?
0
yehudahaCommented:
becaue we moving the file each time and not copying it there is no overwrite issue here.

i tryed the the script without the "\" i got your error. when i put it at the end like i mention

it's work great.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.