title: Application Failed to Initialize Properly (0xc0000142)
body: <p>I'm trying to launch notepad.exe(as a simpler test) from a web service using process.Start().  This web service is deployed to IIS 5.1 on Windows XP (for development) and will likely be deployed to a Windows 2003 server with IIS 6.  This is the code that I am using:</p>
  
  <pre><code>    [WebMethod]
      public String ReqFormImage(String qString)
      {
          _qString = qString;
  
          String imageLoc = @"http://localhost/MobileService/formImages/" + NameOfScreenshot(qString);
  
          Process myProcess = new Process();
          try
          {
              //Credentials
              myProcess.StartInfo.Domain = "domain";
              myProcess.StartInfo.UserName = "myUserName"; //local admin on development pc
              myProcess.StartInfo.Password = PasswordGenerate("removed");
  
              //StartInfo
              myProcess.StartInfo.WorkingDirectory = @"C:\WINDOWS\System32";
              myProcess.StartInfo.FileName = "notepad.exe";
              //myProcess.StartInfo.Arguments = qString;
              myProcess.StartInfo.UseShellExecute = false;
              myProcess.StartInfo.RedirectStandardInput = true;
              myProcess.StartInfo.RedirectStandardOutput = true;
              myProcess.StartInfo.RedirectStandardError = true;
              //myProcess.StartInfo.LoadUserProfile = false;
  
              myProcess.Start();
              myProcess.WaitForExit();
          }
          catch (Exception e)
          {
              Console.WriteLine(e.Message);
          }
  return imageLoc;
      }
  </code></pre>
  
  <p>I also have impersonate set to true in the web.config (I've tried with and without my credentials in the config file, as well as with impersonate set to false).  I've also given read/execute permission to my user ID, aspnet, and the service account on notepad.exe.</p>
  
  <p>A breakpoint on myProcess.WaitForExit() causes a message box to pop up that says, "Application Failed to Initialize Properly (0xc0000142)."  I looked at the event log and there is no further information than this.</p>
  
  <p>What I need in the end is to be able to launch an exe impersonating an account that can be hardcoded or impersonating the user that accesses the web service.  I know that there are issues with opening an exe with a GUI server-side, but I need this to work.  I'm sure this isn't the best practice, but I am running short on time and am looking for a workaround.  For now, at least getting notepad to launch will be sufficient.</p>
  
  <p>Thanks for any help.</p>