title: Service needs to spawn non-interactive child process, but fails with "Access denied"
body: <p>First off, I'm <em>not</em> trying to interact with the desktop in any kind.</p>
  
  <p>What I'm trying to do is to separate concerns. I have a service that runs under the local system account (LSA). Sometimes, I need to execute processes under a different account.</p>
  
  <p>I am using <code>System.Diagnostics.Process</code> for this. This is what I have tried with so far:</p>
  
  <ul>
  <li>Running the service app as an ordinary desktop app, launching the child process under the same account: <strong>works</strong></li>
  <li>Running the service app as an ordinary desktop app, launching the child process under another account: <strong>works</strong></li>
  <li>Running the service as a service app (as LSA), launching the child process under the same account (LSA): <strong>works</strong></li>
  <li>Running the service as a service app (as LSA), launching the child process under another account: <strong>does not work</strong></li>
  </ul>
  
  <p>The case that does not work for me throws me a Win32Exception with "Access denied." I have granted the user account in question the right to log on as a service, but it does not make any difference.</p>
  
  <p>For fun, I have also tried these scenarios:</p>
  
  <ul>
  <li>If I run the service under my own dev account (let's call it Developer), and tries to start the child process under the less privileged account (let's call it ServiceAccount), process.Start() does not throw, and returns true, but I never see any process being started in the Sys Internal's Process Explorer, and <code>Process.Exited</code> is fired immediately.</li>
  <li>If I run the service under ServiceAccount, and starts the child process under the <em>same</em> account (ServiceAccount), it works as expected.</li>
  </ul>
  
  <p>This is the code I'm working with:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var pi = new ProcessStartInfo {
      CreateNoWindow = true,
      WindowStyle = ProcessWindowStyle.Hidden,
      UseShellExecute = false,
      ErrorDialog = false,
      RedirectStandardError = false,
      RedirectStandardInput = false,
      RedirectStandardOutput = false,
      FileName = @"C:\Path\To\SomeApplication.exe",
      Arguments = @"Some arguments",
      UserName = "SomeUserName",
      Domain = "SomeDomain",
      Password = SecureStringUtils.Convert("SomePassword")
  };
  
  var process = new Process();
  process.StartInfo = pi;
  process.Start(); // Throws when run as a service
  </code></pre>
  
  <p>Any ideas?</p>