title: Win32_Process create on remote machine with the target on a share
body: <p>I am trying to execute a program from a ASP.NET website that is located on a share(that points to another machine) on a remote machine. Here is what the configuration looks like</p>
  
  <p>Website server=>Computer A (with share that points to) =>Computer B (exe is here)</p>
  
  <p>If I pass the following argument for the processName z:\tools\bin\myprogram.exe I get a return code of path not found. If I pass the following argument for the process name \\computerB\tools\bin\myprogram.exe I get an access denied error.</p>
  
  <pre><code>private static int CreateRemoteProcess(string serverName, string username, string password, string processName, params string[] arguments)
  {
      var connection = new ConnectionOptions
      {
          Username = username,
          Password = password
      };
  
      var scope = new ManagementScope(@"\\" + serverName + @"\root\cimv2", connection);
      using (var managementClass = new ManagementClass(scope,
                                                      new ManagementPath("Win32_Process"),
                                                      new ObjectGetOptions()))
      {
          var inputParams = managementClass.GetMethodParameters("Create");
          if (arguments != null)
          {
              foreach (var param in arguments)
              {
                  processName += " " + param;
              }
          }
  
          inputParams["CommandLine"] = processName;
          var outParams = managementClass.InvokeMethod("Create",
                                                       inputParams,
                                                       new InvokeMethodOptions());
          outParams = managementClass.InvokeMethod("Create", inputParams, null);
          var ret = Convert.ToInt32(outParams["ReturnValue"]);
          return Convert.ToInt32(outParams["ProcessId"]);
      }
  </code></pre>