I encountered an issue with my ASP application. Upon running a process on the server, I started receiving errors from cscript. Oddly enough, when debugging locally everything functions as expected and the process runs smoothly. However, deploying the application to IIS and running it from another machine's explorer results in crashes at the onset of the process.
My initial thought was that it might be related to the user permissions, so I included the following line in the web.config for reassurance:
<identity impersonate="true" userName="domain\user" password="password" />
Additionally, I made sure to add the specified user for the process initiation, but unfortunately, the page continues to crash. The error message I consistently encounter on the server side whenever the process is triggered (via a button press) is:
cscript.exe - Application Error
The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.
The snippet of code responsible for launching the process is as follows:
public static void updatePerson(csPerson person)
{
string fileName = "card.js";
File.WriteAllText(fileName, person.setFileUpdatePerson(person), 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 = fileName;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UserName = "Administrator";
SecureString password = new SecureString();
string pass = "myPassword";
foreach (char c in pass)
{
password.AppendChar(c);
}
startInfo.Password = password;
proc.StartInfo = startInfo;
proc.Start();
proc.WaitForExit();
proc.Close();
proc.Dispose();
}
If anyone has insights into what could be causing this issue, I would greatly appreciate your input. I've been grappling with this problem all day.
Thank you.