title: Error Code 0xc0000142 starting process from windows service
body: <p>I have a situation occuring when launching Processes from a Windows service</p>
  
  <pre><code> _________
  |         |           * Process 1
  | Service |  -------&gt; * Process ...
  |_________|           * Process n
  </code></pre>
  
  <p>The code used by the service to do so is the following:</p>
  
  <pre><code>    ProcessStartInfo startInfo = new ProcessStartInfo(executablePath, commandlineArgs);
      startInfo.WorkingDirectory = instancePath;
      startInfo.UserName = userB;
      startInfo.Password = passwordSecureString;
      startInfo.Domain = domain;
      startInfo.UseShellExecute = false;
  
      Process process = new Process
      {
        StartInfo = startInfo,
        EnableRaisingEvents = true,
      };
  
      process.Start();
  </code></pre>
  
  <p>Now, I have two accounts - for simplicity's sake, say A and B. The service is being run under the first one and starts the processes using the second one.</p>
  
  <ul>
  <li>Both accounts are in the Local Admin group</li>
  <li>Both accounts have the right to log on as a service</li>
  <li>Secondary logon service is enabled (just in case, should that matter)</li>
  <li>OS: Windows Server 2012 R2.</li>
  </ul>
  
  <p>The following table is supposed to indicate what happens in which account constellation.</p>
  
  <hr>
  
  <pre><code> _______________
  |   |  A  |  B  |      
  |===+=====+=====|
  | A | OK  |  X  |
  |---+-----+-----|
  | B |  X  |  OK |
  |___|_____|_____|
  </code></pre>
  
  <ul>
  <li>OK - Processes start as expected</li>
  <li>X  - The service gets no error, but processes terminate right away.</li>
  </ul>
  
  <p>...which makes me assume that the user change leads to the problem.</p>
  
  <p>Details on the occuring exception: </p>
  
  <p><a href="https://i.stack.imgur.com/70OiA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/70OiA.png" alt="enter image description here"></a></p>
  
  <p>After having read upon Error Code 142, here's what I've tried so far:</p>
  
  <ul>
  <li>Different Server </li>
  <li>Windows Updates </li>
  <li>Redistributable c++ installation</li>
  <li>coffee, followed by strong liquor, then again coffee</li>
  </ul>
  
  <p>Can anyone relate to this issue?</p>