C# System.Diagnostics.Process launches on my local IIS, but doesn't launch on the server

2

I'm trying to make my program to run a bat file, that launches an exe file. It works fine on my local computer, but doesn't work on the server IIS. It doesn't work regardless of whether I specify the username and password in the ProcessStartInfo or not. I've searched forums and applied different stuff, but none of them help.

In Windows event viewer it doesn't give me any errors as well as the process output. If I change a directory and it can't find the bat file, the output gives me an error, but when it finds the file, it doesn't return anything and just doesn't launch the program.

Now, if I provide a credentials for the process, specifying psi.Domain, psi.UserName and psi. Password, the StandartOutput doesn't return any error, but Windows Events gives me two following errors:

Application popup: cmd.exe - Application Error : The application was unable to start correctly (0xc0000142). Click OK to close the application.

And

Application popup: conhost.exe - Application Error : The application was unable to start correctly (0xc0000142). Click OK to close the application.

Here's the code:

    System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\inetpub\CopyToAD\pspasswd\passchange.bat");                
                psi.RedirectStandardOutput = true;
                psi.RedirectStandardInput = true;
                psi.RedirectStandardError = true;
                psi.CreateNoWindow = true;                
                psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                psi.UseShellExecute = false;
                System.Diagnostics.Process listFiles;
                listFiles = new System.Diagnostics.Process();
                listFiles.EnableRaisingEvents = false;
                listFiles.StartInfo = psi;

                listFiles.Start();

                System.IO.StreamReader myOutput = listFiles.StandardOutput;
                listFiles.WaitForExit(2000);
                myOutput.ReadToEnd();
                string output = myOutput.ReadToEnd();
                ViewBag.View6 += output + "***";
                if (listFiles.HasExited)
                {
                    output = myOutput.ReadToEnd();
                    ViewBag.View6 += output;
                }
c#
iis
system.diagnostics
asked on Stack Overflow Mar 31, 2015 by Roman • edited Apr 1, 2015 by Roman

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0