Dim fso, result, source, destination
destination = "D:\destination_folder"
Set fso = CreateObject("Scripting.FileSystemObject")
result = fso.CopyFolder(source, destination, true)
Error: Permission Denied
Source: Microsoft VBScript runtime error
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Dim oShell, source, destination
source = "C:\myFolder\*"
destination = "D:\myOtherFolder"
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "xcopy.exe " & source & " " & destination & " /R /Y"
Set oShell = Nothing
- The /Y switch may be preset in the COPYCMD environment variable. If you want the prompt to appear, you can use the /-Y version of the /Y switch. The /-Y version of the switch turns off the /Y switch that is preset in the COPYCMD environment variable.
- The XCOPY utility is not available in Windows Vista. To resolve this issue in Windows Vista, use the Robocopy.exe file instead of the Xcopy.exe file in the code example.
Article ID: 941190 - Last Review: Aug 14, 2012 - Revision: 1