How To: Copy a Folder and Its Contents Using VBS

The script below uses the CopyFolder method to copy the contents of C:\Scripts to C:\Temp, overwriting any existing files in the destination folder. Note that this will not result in a folder named C:\Temp\Scripts; instead, the folder C:\Temp will simply contain the same files and folders as C:\Scripts. To create a folder named C:\Temp\Scripts, you would need to specify C:\Temp\Scripts as the destination folder.


Const OverWriteFiles = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Scripts", "C:\Temp", OverWriteFiles

No comments:

Post a Comment