Copies an item or items to a folder.
Syntax
Folder.CopyHere(vItem [, vOptions])
Parameters
vItem Required. The item or items to copy. This can be a string that represents a file name, a FolderItem object, or a FolderItems object.vOptions Optional. Options for the copy operation. This value can be zero or a combination of the following values. These values are based upon flags defined for use with the fFlags member of the C++ SHFILEOPSTRUCT structure. These flags are not defined as such for Microsoft Visual Basic, Visual Basic Scripting Edition (VBScript), or Microsoft JScript, so you must define them yourself or use their numeric equivalents.4Do not display a progress dialog box. 8Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists. 16Respond with "Yes to All" for any dialog box that is displayed. 64Preserve undo information, if possible.128Perform the operation on files only if a wildcard file name (*.*) is specified. 256Display a progress dialog box but do not show the file names. 512Do not confirm the creation of a new directory if the operation requires one to be created. 1024Do not display a user interface if an error occurs. 2048Version 4.71. Do not copy the security attributes of the file.4096Only operate in the local directory. Don't operate recursively into subdirectories.9182Version 5.0. Do not copy connected files as a group. Only copy the specified files.
4
8
16
64
128
256
512
1024
2048
4096
9182
Return Value
No return value.
Remarks
Note Not all methods are implemented for all folders. For example, the ParseName method is not implemented for the Control Panel folder (CSIDL_CONTROLS). If you attempt to call an unimplemented method, a 0x800A01BD (decimal 445) error is raised.
Examples
The following example uses CopyHere to copy the Autoexec.bat file from the root directory to the C:\Windows directory. Proper usage is shown for JScript, VBScript, and Visual Basic. JScript: <script language="JScript"> function fnCopyHereJ() { var objShell = new ActiveXObject("Shell.Application"); var objFolder = new Object; objFolder = objShell.NameSpace("C:\\WINDOWS"); if (objFolder != null) { objFolder.CopyHere("C:\\AUTOEXEC.BAT"); } } </script> VBScript: <script language="VBScript"> function fnCopyHereVB() dim objShell dim objFolder set objShell = CreateObject("Shell.Application") set objFolder = objShell.NameSpace("C:\WINDOWS") if not objFolder is nothing then objFolder.CopyHere("C:\AUTOEXEC.BAT") end if set objShell = nothing set objFolder = nothing end function </script> Visual Basic: Private Sub btnCopyHere_Click() Dim objShell As Shell Dim objFolder As Folder Set objShell = New Shell Set objFolder = objShell.NameSpace("C:\WINDOWS") If (Not objFolder Is Nothing) Then objFolder.CopyHere ("C:\AUTOEXEC.BAT") End If Set objFolder = Nothing Set objShell = Nothing End Sub
JScript:
<script language="JScript"> function fnCopyHereJ() { var objShell = new ActiveXObject("Shell.Application"); var objFolder = new Object; objFolder = objShell.NameSpace("C:\\WINDOWS"); if (objFolder != null) { objFolder.CopyHere("C:\\AUTOEXEC.BAT"); } } </script>
VBScript:
<script language="VBScript"> function fnCopyHereVB() dim objShell dim objFolder set objShell = CreateObject("Shell.Application") set objFolder = objShell.NameSpace("C:\WINDOWS") if not objFolder is nothing then objFolder.CopyHere("C:\AUTOEXEC.BAT") end if set objShell = nothing set objFolder = nothing end function </script>
Visual Basic:
Private Sub btnCopyHere_Click() Dim objShell As Shell Dim objFolder As Folder Set objShell = New Shell Set objFolder = objShell.NameSpace("C:\WINDOWS") If (Not objFolder Is Nothing) Then objFolder.CopyHere ("C:\AUTOEXEC.BAT") End If Set objFolder = Nothing Set objShell = Nothing End Sub
Applies To
Folder
See Also