cscript crashes when starting a process from ASP.NET Application
I´m having a problem with my ASP application. I´m getting an error from the cscript when I run a process on the server. When I debug locally the page just works fine 开发者_如何学Cand the process is executed correctly, but when I deploy the application to the IIS and run it from another machine explorer it crashes when the process starts.
I imagine it was a matter of the user, so I added this line to the web.config, to ensure that.
<identity impersonate="true" userName="domain\user" password="password" />
Then, I added the user that I wanted the process to start with but the page keeps crashing. The error that I get in the server side each time the process is launch (when a button is pressed) is:
cscript.exe - Application Error
The application failed to initialize properly (0xc0000142). Click on OK to terminate the application
The code that launches the process is:
public static void actualizarPersona(csPersona persona)
{
string nombreArchivo = "card.js";
File.WriteAllText(nombreArchivo, persona.setFileActualizarPersona(persona), Encoding.GetEncoding(1252));
Process proc = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.FileName = "cscript.exe";
startInfo.Arguments = nombreArchivo;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UserName = "Administrator";
SecureString password = new SecureString();
string contraseña = "myPassword";
foreach (char c in contraseña)
{
password.AppendChar(c);
}
startInfo.Password = password;
proc.StartInfo = startInfo;
proc.Start();
proc.WaitForExit();
proc.Close();
proc.Dispose();
}
Does anyone have any idea of what may be happening?. I´ve been stuck here for a while today.
Thanks you.
You may need to load the user's profile
startInfo.LoadUserProfile = true
Edit
Try creating a new app pool with a a new admin account. If that works remove the user from the admin group and create a new group with the necessary permissions for the app.
(see trying to run a process from an asp.net application)
精彩评论