title: File Folder copy
body: <p>Below is the VBScript code. If the file/s or folder exist I get scripting error, "File already exists".</p>
  
  <ul>
  <li>How to fix that?</li>
  <li>How to create folder only if it does not exist and copy files only that are new or do not exist in source path?</li>
  <li>How to insert the username (Point 1) after "Welcome" and at (Poin 3) instead of user cancelled?</li>
  <li>Can the buttons be changed to Copy,Update,Cancel instead of Yes,No,Cancel? (Point 2)</li>
  </ul>
  
  <p>The code:</p>
  
  <pre><code>Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set wshShell = WScript.CreateObject( "WScript.Shell" )
  strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
  Message = "       Welcome to the AVG Update Module" &amp; vbCR '1*
  Message = Message &amp; "       *****************************" &amp; vbCR &amp; vbCR
  Message = Message &amp; "        Click Yes to  Copy   Definition Files" &amp; vbCR &amp; vbCR
  Message = Message &amp; "                            OR  " &amp; vbCR &amp; vbCR
  Message = Message &amp; "        Click  No to Update  Definition Files." &amp; vbCR &amp; vbCR
  Message = Message &amp; "        Click  Cancel (ESC) to Exit." &amp; vbCR &amp; vbCR
  X = MsgBox(Message, vbYesNoCancel, "AVG Update Module") '2*
  'Yes Selected Script
  If X = 6 then
      objFSO.FolderExists("E:\Updates")
      if TRUE then objFSO.CreateFolder ("E:\Updates")
      objFSO.CopyFile "c:\Docume~1\alluse~1\applic~1\avg8\update\download\*.*",
      "E:\Updates\" ,   OverwriteFiles
      MsgBox "Files Copied Succesfully.", vbInformation, "Copy Success"
  End If
  'No Selected Script
  If X = 7 then
      objFSO.FolderExists("Updates")
      if TRUE then objFSO.CreateFolder("Updates")
      objFSO.CopyFile "E:\Updates\*.*", "Updates", OverwriteFiles
      Message =  "Files Updated Successfully."  &amp; vbCR &amp; vbCR
      Message = Message &amp; "Click  OK to Launch AVG GUI." &amp; vbCR &amp; vbCR
      Message = Message &amp; "Click  Cancel (ESC) to Exit." &amp; vbCR &amp; vbCR
      Y = MsgBox(Message, vbOKCancel, "Update Success")
      If Y = 1 then
          Set WshShell = CreateObject("WScript.Shell")
          WshShell.Run chr(34) &amp; "C:\Progra~1\avg\avg8\avgui.exe" &amp; Chr(34), 0
          Set WshShell = Nothing
      End if
      If Y = 3 then WScript.Quit
  End IF
  'Cancel Selection Script
  If X = 2 then
      MsgBox "No Files have been Copied/Updated.", vbExclamation, "User Cancelled" '3*
  End if
  </code></pre>
  
  <hr>