VBScript to copy all files from one network folder to a local folder

Posted on 2012-08-16
Medium Priority
Last Modified: 2012-08-17
Hello All,

After a trawl of the internet, I'm struggling to find/adapt a suitable script that will copy all files from a network folder to a users local profile.

For example, this code works perfectly fine:
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\srv-fp01\d$\Public\Shortcuts\*.*" , "c:\test\" , OverwriteExisting

However, what I would like to achieve is for the destination folder to be this:

If I try this, then I get a vb error (Path not found).  I know the source is OK but I am guessing that the %username% is throwing a spanner in the works.

As you probably can tell, I'm no good at VBScripts  ;-)

What I am trying to do is when a user logs on, the vbscript fires and copies urls into their favourites bar...

Thanks in advance!
Question by:JamieD71
1 Comment
LVL 60

Accepted Solution

Bill Prew earned 2000 total points
ID: 38303105
Give this a go:

Const OverwriteExisting = True
Set objShell = CreateObject( "WScript.Shell" )
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "\\srv-fp01\d$\Public\Shortcuts\*.*", objShell.ExpandEnvironmentStrings("c:\users\%username%\favorites\links\"), OverwriteExisting

Open in new window


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…

627 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