title: Running commands on remote machine
body: <p>I have written a wmi application which runs a batch file on a remote machine.</p>
  
  <p>This batch file writes the output to the directory-string passed to it as  an argument.</p>
  
  <p>When I launch my application, and choose drive C as the output directory, everything works.
  But, when I choose a network drive, it doesn't work, for some reason.</p>
  
  <p>(This network drive is the company's users drive, and mapped for each user on the network).</p>
  
  <p>If I run the same exact command (with the network drive) manually from within the remote machine, it also works...</p>
  
  <pre><code>ConnectionOptions connOptions = new ConnectionOptions();
  connOptions.Impersonation = ImpersonationLevel.Impersonate;
  connOptions.Username = sUsername;
  connOptions.Password = sPassword;
  connOptions.Authority = "NTLMDomain:" + sDomain;
  connOptions.EnablePrivileges = true;
  ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", sHost), connOptions);
  manScope.Connect();
  ManagementPath managementPath = new ManagementPath("Win32_Process");
  ManagementClass processClass = new ManagementClass(manScope, managementPath, objectGetOptions);
  ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
  
  for (int i = 0; i &lt; listOfJobs.Items.Count; i++)
  {
     listOfJobs.SetSelected(i, true);
     inParams["CommandLine"] = listOfJobs.SelectedItem.ToString();
     ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
  }
  </code></pre>
  
  <p>Example for job strings:</p>
  
  <blockquote>
    <p>Working script: C:\Scripts\BatchScript -p C:\Test C:\OutputDir</p>
    
    <p>Failing script: C:\Scripts\BatchScript -p C:\Test U:\OutputDir</p>
  </blockquote>
  
  <p>Any ideas?</p>