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

Posted on 2012-08-16
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 51

    Accepted Solution

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
    This is an addendum to the following article: Acitve Directory based Outlook Signature ( The script is fine, and works in normal client-server domains…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now