How do your overwrite a folder using VB Script - FSO.CopyFolder?

Posted on 2007-08-10
Last Modified: 2012-08-14
I have a script that copies a users favorites to the server when they logout and copies down from the server in the login script locally.  Its working as it should however I can not figure out have to overwrite the directory as both scripts seem to append the contents rather than overwrite it.

sample from the log in script:

Sub copyfav()
dim ndomain,ufav,struser

strUser = WSHNetwork.UserName

 strStatus = strStatus & vbCRLF & vbCRLF & "Copying Favorites from U drive...."
 ie.document.all.wstatus.InnerText = strStatus

ndomain = ".mydomain"
ufav = "u:\Favorites"

Set objFSO = CreateObject("Scripting.FilesystemObject")      
strfavPath = "C:\Documents and Settings\" & struser & "\Favorites"
If objFSO.FolderExists(strfavPath) = False Then
   strfavPath = "C:\Documents and Settings\" & struser & ndomain & "\Favorites"
End If

if objFSO.FolderExists(ufav) = true Then
objFSO.CopyFolder "u:\Favorites", strfavPath, "true"
end if
Set objFSO = Nothing

end sub
Question by:djpazza
    LVL 33

    Expert Comment

    use this
        objFSO.CopyFolder "u:\Favorites", strfavPath, true
    LVL 33

    Expert Comment

    If you wish to "truly" overwrite, then I suggest you delete the folder then copy to the destination
    LVL 33

    Accepted Solution

    To remove a folder,

    objFso.DeleteFolder "yourfolderhere", True
    LVL 9

    Author Comment

    I tried objFSO.CopyFolder "u:\Favorites", strfavPath, true already and that did not work

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Share codes 68 103
    Excel Macro - Promt to replace partial content of cell 7 37
    Exit Loop after User Input 4 24
    Check version 13 42
    Often times network admins need to run domain logon scripts for seperate subnets, but also for a seperate set of computers within that subnet.  In this circumstance, configuring Active Directory Sites and Services then linking a GPO to site/subnet m…
    This is an addendum to the following article: Acitve Directory based Outlook Signature ( The script is fine, and works in normal client-server domains…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now