ASP.NET Process.Start not working on IIS8 (Windows 8.1)

拜拜、爱过 提交于 2020-02-08 08:51:13

问题


I've been trying to get this working for the past couple of days and tried every solution suggested including the one here:

System.Diagnostics.Process.Start not work from an IIS

This code (ASP.NET MVC Web Application) works perfectly on IIS7 (Windows 7).

The code just print a PDF file using Adobe Reader in a local printer (intranet) from the server:

// print receipt
ProcessStartInfo psInfo = new ProcessStartInfo();
psInfo.FileName = acrobatReaderPath;
psInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(psInfo.FileName);
psInfo.Arguments = String.Format("/s /o /h /t \"{0}\" \"{1}\"", filePath, printerName);
psInfo.WindowStyle = ProcessWindowStyle.Hidden;
psInfo.CreateNoWindow = true;
psInfo.UseShellExecute = true;
Process process = Process.Start(psInfo);

The Application Pool Identity is a local privileged account. Like I said before, it works on IIS7.

The strange thing is that I can see the background process started (AcroRd32.exe) in the Task Manager including the Command Line used to launch it. If I copy the Command Line and run it the PDF prints without problem.

Is there something I'm missing?

I know there are better ways to do this. Suggestions are also welcome.

UPDATE:

Clarification: The issue is that the process is not finishing and the PDF is not printing.

Apparently the issue is more of a bitness (32 vs 64). I'm still debugging.

The code IS PRINTING the PDFs in the following scenarios:

  • Visual Studio 2012 IIS Express on Windows 7 (64 bits)
  • IIS7 on Windows Server 2008 Standard (32 bits)

The code IS NOT PRINTING the PDFs in the following scenarios:

  • Visual Studio 2012 IIS7 on Windows 7 (64 bits)
  • IIS8 on Windows 8.1 (64 bits)

The application pool is running with an Administrator account and the Enable 32-Bit Applications is set to True in Advance Settings.

The World Wide Web Publishing Service (W3SVC) has the Allow service to interact with desktop checked in the Properties.

Please let me know if anyone knows how to solve this. Thanks.


回答1:


Changed Acrobat Reader for Foxit Reader (https://www.foxitsoftware.com/products/pdf-reader/) and it solved the problem. The command line is very similar.



来源:https://stackoverflow.com/questions/31779138/asp-net-process-start-not-working-on-iis8-windows-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!