C # code to run a batch file works in a console application, but the same code does not work in a WCF service

This following code is pretty simple and works in a console application. But for some reason, it does not work in the WCF service. A directory that has a batch file has full permissions. Can anybody help me? What am I missing?

    try
        {
            ProcessStartInfo psi = new ProcessStartInfo();

            //specify the name and the arguements you want to pass
            psi.FileName = ConfigurationManager.AppSettings["BatchFileLocation"];
            psi.Arguments = filePath; 

            //Create new process and set the starting information
            Process p = new Process();
            p.StartInfo = psi;

            //Set this so that you can tell when the process has completed
            p.EnableRaisingEvents = true;

            p.Start();

            //wait until the process has completed
            while (!p.HasExited)
            {
                System.Threading.Thread.Sleep(1000);
            }

            //check to see what the exit code was
            if (p.ExitCode != 0)
            {
                logger.Write(p.ExitCode);
            }
        }
        catch (Exception ex)
        {
            logger.Write(ex.Message);
        }
+3
source share
1 answer

I assume this is an IIS Hosted WCF Service.

Check the identifier associated with the application pool.

IIS 7 6.0, , NetworkService, , SFTP .. 7.5 : , IIS 7.5. , , , .

0

Source: https://habr.com/ru/post/1775069/


All Articles