Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2007-08-10
4
Medium Priority
?
2,714 Views
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
0
Comment
Question by:djpazza
  • 3
4 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 19670313
use this
    objFSO.CopyFolder "u:\Favorites", strfavPath, true
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19670317
If you wish to "truly" overwrite, then I suggest you delete the folder then copy to the destination
0
 
LVL 33

Accepted Solution

by:
hongjun earned 150 total points
ID: 19670338
To remove a folder,

objFso.DeleteFolder "yourfolderhere", True
0
 
LVL 9

Author Comment

by:djpazza
ID: 19670396
I tried objFSO.CopyFolder "u:\Favorites", strfavPath, true already and that did not work
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

581 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