title: Win32_Process.Create() can launch local files but not network files
body: <p>I am attempting to remotely call an executable on a target machine, with the executable located on a UNC network path. I am using the <code>Win32_Process.Create</code> method to do this. I am able to use this method to launch files that are stored locally on the C: drive, but I get Return Value 2, <code>Access Denied</code>, when I try to launch the file from a UNC path. I am confident the path is correct, because if I alter it to a bogus path, I get Return Value 9, <code>Path Not Found</code>. </p>
  
  <p>In Powershell I am using <code>invoke-wmimethod</code> to call the Create method of Win32_Process and passing a <code>credential</code> object that has administrative rights on the target system and read rights on the UNC path. In C# I am impersonating using <code>ConnectionOptions</code> with the same credentials. The results are the same in both cases.</p>
  
  <p>I have also tried using various methods (CIM_DataFile, remotely invoking XCopy) to copy the EXE file locally first. None of these methods have worked. I want to copy directly from a file server, to a target system, without pulling the file to the application server first, because the application server is not in the same datacenter as most target systems and as such would be pulling a large file down over the WAN twice, which is slow and less reliable. One option I have found is to use FTP, but I consider that a last resort.</p>
  
  <p>I can also remotely invoke the EXE from the UNC path using PSExec and the same credentials, but I want to avoid shelling out from my web application to call PSExec. I know it will work if that's what I have to do, and I have used PSExec many times to solve problems like this, but I really want to do this all within the application and not hacking around it using an external program.</p>
  
  <p>Is there any way I can use Win32_Process to launch an EXE on a remote machine, when that EXE is located on a UNC path? Could this be a Group Policy issue wherein the process launched by WMI does not have permission to invoke an EXE from a network location? I am out of ideas and out of search terms.</p>
  
  <p>Powershell code examples. This works:</p>
  
  <p><code>$launchproc = Invoke-WmiMethod -ComputerName $compName -Class Win32_process -Name Create -ArgumentList "c:\temp\installer.exe /s /f1c:\temp\installer.iss" #-Credential $adminCreds</code></p>
  
  <p>This does not:</p>
  
  <p><code>$launchproc = Invoke-WmiMethod -ComputerName $compName -Class Win32_process -Name Create -ArgumentList "\\fileserver\share\installer.exe /s /f1\\fileserver\share\installer.iss" -Credential $adminCreds</code></p>
  
  <p>Note that if I issue the command locally from a command window, interactively, the UNC based command DOES work just fine. The funny syntax is an artifact of InstallShield's silent install switches. Also note that if I double-backslash or backtick escape the backslashes, I get Path Not Found, so I don't think it's an escaping issue.</p>
  
  <p>Edit: while not exactly the same problem, I did check the GP rights described here: <a href="https://stackoverflow.com/questions/767010/wmi-win32-process-create-fails-with-insufficient-privs?rq=1">WMI Win32_Process.Create fails with Insufficient Privs</a> and I do have those rights set correctly.</p>
  
  <p>Edit #2: I found someone else having a similar problem: <a href="http://social.msdn.microsoft.com/forums/en-US/d12548ee-ddd3-4e30-bbdb-eaf0e4f39f4c/win32process-create-method-trying-to-copy-a-file-from-a-remote-machine-to-a-remote-machine" rel="nofollow noreferrer">
  Win32_Process Create method. Trying to copy a file from a remote machine to a remote machine</a> Again it's a batch file-ish hack launching Net Use on the remote system. Is this my only real option?</p>