I'm unable to use Process.Start
to start a simple console application when I specify user credentials. It appears that the call to Process.Start
tries to start the application, but the application immediately fails with an event log entry (see below). I'm running IIS 7.5/.NET 4.0 on a Windows 7 Ultimate (x64) machine. Application pool runs under ApplicationPoolIdentity and uses Integrated Mode. Web site is set to run under Full Trust.
To test, I created a simple console application, ConsoleApplication1
, that simply writes "Hello World" to the console and appends the current date and time to a text file, just so I can see that the application executed. When I run the application from a button click in my ASP.NET app using the following code, I see a new value get written into my 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 my text file, and I see a message in the Event Viewer that states:
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'm pretty sure the authentication of the user credentials is working properly, because I get a Logon failure: unknown user name or bad password
error if I enter incorrect info.
I feel like I must be missing something simple, but can anyone point me in the right direction here?