title: WMI remote process to copy file
body: <p>Long story short, my application needs to copy a file to a remote target where UNC connections TO the target might not be possible. However UNC connections FROM the target and BACK to the server will always be possible. So the plan was to use WMI to start a remote command shell (cmd) and use the copy command to grab the file. But this doesn't work. The following command works fine when executed manually from the command line of the target:</p>
  
  <pre><code>copy \\192.168.100.12\c$\remotefile.txt c:\localfile.txt
  </code></pre>
  
  <p>But when I try this same command as part of the <code>InputParameters("CommandLine")</code> it does not work, and produces no error. Note that I <em>can</em> use WMI to connect to the target and remote execution works just fine as I can start calc.exe etc. Here is the code that doesn't work:</p>
  
  <pre><code>Dim ConnectionOptions As New System.Management.ConnectionOptions
      With ConnectionOptions
          .Username = "target\Administrator"
          .Password = "password"
      End With
  
      Dim ManagementScope As New System.Management.ManagementScope("\\192.168.100.11\root\cimv2", ConnectionOptions)
      Try
          ManagementScope.Connect()
          MsgBox("connected")
          Dim ManagementPath As New System.Management.ManagementPath("Win32_Process")
          Dim ManagementOptions As New System.Management.ObjectGetOptions
          Dim ManagementClass As New System.Management.ManagementClass(ManagementScope, ManagementPath, ManagementOptions)
          Dim InputParameters As System.Management.ManagementBaseObject = ManagementClass.GetMethodParameters("Create")
          InputParameters("CommandLine") = "cmd /c copy \\192.168.100.12\c$\remotefile.txt c:\localfile.txt"
          Dim OutputParameters As System.Management.ManagementBaseObject = ManagementClass.InvokeMethod("Create", InputParameters, Nothing)
          MsgBox("done")
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  </code></pre>
  
  <p>Any ideas why this isn't working? Or does anyone have a better way of doing what I'm trying to do?</p>