[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB Script to move IE favorites.

Posted on 2009-02-09
12
Medium Priority
?
753 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:ziplizzard
  • 6
  • 6
12 Comments
 
LVL 14

Expert Comment

by:yehudaha
ID: 23597357
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
 

Author Comment

by:ziplizzard
ID: 23601701
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
 
LVL 14

Expert Comment

by:yehudaha
ID: 23602899
change this:
strDest = "\\servername\Users\" & strUser & "\Favorites"

to this:
strDest = "\\servername\Users\" & strUser & "\Favorites\"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:yehudaha
ID: 23602906
notice to the "\" at the end
0
 

Author Comment

by:ziplizzard
ID: 23603714
Same error.
0
 

Author Comment

by:ziplizzard
ID: 23603749
A copy might work rather than a move, but how do you copy items in subfolders as well?
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 23604371
what is the exact error ?
0
 

Author Comment

by:ziplizzard
ID: 23604713
Error: File already Exists
error.jpg
0
 
LVL 14

Accepted Solution

by:
yehudaha earned 1500 total points
ID: 23604827
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
 

Author Comment

by:ziplizzard
ID: 23605693
I am getting the same error.
0
 

Author Comment

by:ziplizzard
ID: 23605811
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
 
LVL 14

Expert Comment

by:yehudaha
ID: 23608306
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question