title: Copying 2 files into a path of the current user profile
body: <p>I am trying to copy a couple of files in the following path:</p>
  
  <p>C:\Users\username\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin\adobeconnectaddin</p>
  
  <p>I am using VBS and the script I am using is as follows:</p>
  
  <pre><code>DestinationFile1 = ("C:\Users" + Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin\adobeconnectaddin\adobeconnectaddin.exe")
  DestinationFile2 = ("C:\Users" + Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin\adobeconnectaddin\digest.s")
  SourceFile1 = "adobeconnectaddin.exe"
  SourceFile2 = "digest.s"
  path=CreateObject("WScript.Shell").ExpandEnvironmentStrings("%UserProfile%")
  DestinationPath = ("C:\Users" + path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin\adobeconnectaddin")
  Dim objNetwork
  Dim userName
  Dim FSO
  Dim Folder
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set objNetwork = CreateObject("WScript.Network")
  userName = objNetwork.userName
  If NOT (FSO.FolderExists(Path + "\AppData\Roaming\Macromedia")) Then
  
  
      FSO.CreateFolder(Path + "\AppData\Roaming\Macromedia")
  End If
  If NOT (FSO.FolderExists(Path + "\AppData\Roaming\Macromedia\Flash Player")) Then
      ' Delete this if you don't want the MsgBox to show
      'MsgBox("Local folder doesn't exists, creating...")
  
      ' Create folder
      'MsgBox("C:\" + splitString(2) + "\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client")
      FSO.CreateFolder(Path + "\AppData\Roaming\Macromedia\Flash Player")
  End If
  If NOT (FSO.FolderExists(Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com")) Then
      ' Delete this if you don't want the MsgBox to show
      'MsgBox("Local folder doesn't exists, creating...")
  
      ' Create folder
      'MsgBox("C:\" + splitString(2) + "\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile")
      FSO.CreateFolder(Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com")
  End If
  If NOT (FSO.FolderExists(Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin")) Then
      ' Delete this if you don't want the MsgBox to show
      'MsgBox("Local folder doesn't exists, creating...")
  
      ' Create folder
      'MsgBox("C:\" + splitString(2) + "\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile")
      FSO.CreateFolder(Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin")
  End If
  If NOT (FSO.FolderExists(Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin\adobeconnectaddin")) Then
      ' Delete this if you don't want the MsgBox to show
      'MsgBox("Local folder doesn't exists, creating...")
  
      ' Create folder
      'MsgBox("C:\" + splitString(2) + "\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile")
      FSO.CreateFolder(Path + "\AppData\Roaming\Macromedia\Flash Player\www.macromedia.com\bin\adobeconnectaddin")
  End If
  'All folders created, if non-existent
  
  'Check to see if the files already exists in the destination folder
  
  If fso.FileExists(DestinationFile1) Then
          'Check to see if the file is read-only
          If Not fso.GetFile(DestinationFile1).Attributes And 1 Then 
              'The file exists and is not read-only.  Safe to replace the file.
              fso.CopyFile SourceFile1, DestinationPath, True
          Else 
              'The file exists and is read-only.
              'Remove the read-only attribute
              fso.GetFile(DestinationFile1).Attributes = fso.GetFile(DestinationFile1).Attributes - 1
              'Replace the file
              fso.CopyFile SourceFile1, DestinationPath, True
              'Reapply the read-only attribute
              fso.GetFile(DestinationFile1).Attributes = fso.GetFile(DestinationFile1).Attributes + 1
          End If
      Else
          'The file does not exist in the destination folder.  Safe to copy file to this folder.
          fso.CopyFile SourceFile1, DestinationPath, True
      End If
  If fso.FileExists(DestinationFile2) Then
          'Check to see if the file is read-only
          If Not fso.GetFile(DestinationFile2).Attributes And 1 Then 
              'The file exists and is not read-only.  Safe to replace the file.
              fso.CopyFile SourceFile2, DestinationPath, True
          Else 
              'The file exists and is read-only.
              'Remove the read-only attribute
              fso.GetFile(DestinationFile2).Attributes = fso.GetFile(DestinationFile2).Attributes - 1
              'Replace the file
              fso.CopyFile SourceFile2, DestinationPath, True
              'Reapply the read-only attribute
              fso.GetFile(DestinationFile2).Attributes = fso.GetFile(DestinationFile2).Attributes + 1
          End If
      Else
          'The file does not exist in the destination folder.  Safe to copy file to this folder.
          fso.CopyFile SourceFile2, DestinationPath, True
      End If
  Set fso = Nothing
  </code></pre>
  
  <p>Now, when I run it, I get an error: Bad file name or Number.</p>
  
  <p>Points to note:</p>
  
  <ol>
  <li>The folder structure gets created fine</li>
  <li>Error copy for the copyfile tasks.</li>
  </ol>