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

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
LVL 9
djpazzaAsked:
Who is Participating?
 
hongjunCommented:
To remove a folder,

objFso.DeleteFolder "yourfolderhere", True
0
 
hongjunCommented:
use this
    objFSO.CopyFolder "u:\Favorites", strfavPath, true
0
 
hongjunCommented:
If you wish to "truly" overwrite, then I suggest you delete the folder then copy to the destination
0
 
djpazzaAuthor Commented:
I tried objFSO.CopyFolder "u:\Favorites", strfavPath, true already and that did not work
0
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.

All Courses

From novice to tech pro — start learning today.