You try to use the following code to copy the contents of a specific folder to a destination folder that contains a read-only file:This behavior is expected. Typically, you receive a "Permission Denied" error message when the filesystemobject.copyfolder method encounters a read-only destination file. However, you can drag a file to a folder that contains a read-only file of the same name. In this case, you receive the following message in Windows Explorer:
Dim fso, result, source, destination
source= "C:\source_folder"
destination = "D:\destination_folder"
Set fso = CreateObject("Scripting.FileSystemObject")
result = fso.CopyFolder(source, destination, true)
Note In this code, source_folder represents the actual source folder name, and destination_folder represents the actual destination folder name.
When you run this code, you receive the following error message in the Windows Script Host dialog box:Script: C:\folderName\test.vbs
Line: 3
Char: 1
Error: Permission Denied
Code: 800A0046
Source: Microsoft VBScript runtime error
Line: 3
Char: 1
Error: Permission Denied
Code: 800A0046
Source: Microsoft VBScript runtime error