title: How to make VBScript copy permissions along with files
body: <p>This is all in Windows XP utilizing VBScript.</p>
  
  <p>I have a directory with several files inside.  The files have varying permissions set.  I need to be able to copy the files to a new directory while retaining the permissions.  Using the script below the copy works fine but the permissions are overwritten by the new parent folder.</p>
  
  <p>I am aware of xcopy but I am unsure how to make it work within the script.  Using robocopy is a slight possibility but should be avoided if at all possible.  Other utilities are out of the question due to network contraints.</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <pre><code>Dim CopyFromPath, CopyToPath  
  Const WINDOW_HANDLE = 0 
  Const NO_OPTIONS = 0 
  Const OverwriteExisting = TRUE 
  
  Set objShell = CreateObject("Shell.Application")  
  Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE,"Select folder to copy:",NO_OPTIONS,ssfDRIVES) 
  
  if (not objFolder is nothing) then 
      Set objFolderItem = objFolder.Self  
      CopyFromPath = objFolderItem.Path 
  else  
      Set objShell = nothing 
      WScript.Quit(0) 
  end if 
  
  Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "Where should the folder be copied to?:", NO_OPTIONS, ssfDRIVES)  
  if (not objFolder is nothing) then 
      Set objFolderItem = objFolder.Self  
      CopyToPath = objFolderItem.Path 
  else  
      Set objShell = nothing 
      WScript.Quit(0) 
  end if 
  
  Set objFolder = nothing 
  Set objFolderItem = nothing 
  Set objShell = nothing 
  
  Set objFSO = CreateObject("Scripting.FileSystemObject") 
  objFSO.CopyFile CopyFromPath &amp; "\*.*", CopyToPath &amp; "\", OverwriteExisting 
  msgbox "The folder has now been copied to " &amp; CopyToPath 
  </code></pre>