I cannot use Process.Start to run a simple console application when I Process.Start user credentials. It appears that a call to Process.Start trying to start the application, but the application immediately crashes with an event log entry (see below). I am running IIS 7.5 / .NET 4.0 on a Windows 7 Ultimate (x64) machine. The application pool runs under ApplicationPoolIdentity and uses integrated mode. The website is configured to run under full trust.
For testing, I created a simple console application ConsoleApplication1 , which simply writes "Hello World" to the console and adds the current date and time to a text file, so I see that the application is complete. When I launch the application using the click button in my ASP.NET application using the following code, I see that the new value is being written to a text file, as expected.
protected void btnStart_Click(object sender, EventArgs e) { Process.Start(@"C:\dump\test\ConsoleApplication1.exe"); }
When I try to specify a set of user credentials to run the application using the code below, nothing is written to the text file, and I see a message in the event viewer that reads:
Application popup: ConsoleApplication1.exe - Application Error : The application was unable to start correctly (0xc0000142). Click OK to close the application.
Here is the code that causes the error:
protected void btnStart_Click(object sender, EventArgs e) { Process.Start(@"C:\dump\test\ConsoleApplication1.exe", "myusername", CreatePassword("mypassword"), string.Empty); } private static SecureString CreatePassword(IEnumerable<char> password) { var ss = new SecureString(); foreach (var c in password) ss.AppendChar(c); return ss; }
I am sure that user credential authentication works correctly because I get a Logon failure: unknown user name or bad password error if I enter the wrong information.
I feel like I need to skip something simple, but can someone point me in the right direction?