title: How to start a process from an IIS hosted WCF service?
body: <p>I would like to run a process from an intranet client on the WCF service side. In my case a client asks a server to create a new process on the server's machine under the provided credentials. WCF service is hosted on IIS 7.5 and I start a process using this code</p>
  
  <pre><code>var processInfo = new ProcessStartInfo("C:\\Windows\\System32\\notepad.exe")
  {
      UserName = "some user",
      Password = MakeSecureString("some password"),
      UseShellExecute = false,
      LoadUserProfile = true
  };
  
  Process process = Process.Start(processInfo);
  </code></pre>
  
  <p>This code works if I host WCF service as a self-hosted console application running under admin user and I see the notepad started under another user. It fails on IIS with no exception, but process is immediately terminated</p>
  
  <pre><code>process.HasExited = true;
  process.ExitCode = -1073741502;
  </code></pre>
  
  <p>On IIS WCF application is running under the user with admin rights and has got full trust defined in web.config. I cannot use self  hosted application as it doesn't support easy continuous delivery (like WebDeploy with IIS web farms).</p>
  
  <p><strong>Q:</strong> How can I start a process on a server side from WCF service hosted on IIS?</p>
  
  <p>EDIT:<br>
  I stumbled upon this <a href="http://www.astahost.com/info.php/creating-process-alternate-credentials-createprocessasuser_t12663.html" rel="noreferrer">post</a>, with similar issues and I tried all the methods there, including all possible variations for Process.Start and P/Invoke with CreateProcessWithLogonW and CreateProcessAsUser I also tried granting additional permissions to users. Non of this would work with the error messages identical to the ones the guy had posted.</p>