Access Denied while using System.Diagnostics.Proce

2019-09-07 05:55发布

问题:

I am trying to use the unmanaged ImageMagick library in my ASP.NET application from the command line using System.Diagnostics.Process. Basically, users will upload an .eps file to the site, and then I will run the command line command to convert it into .jpg. This is the code I'm using to try and run the command:

        Dim proc As New System.Diagnostics.Process
        proc.StartInfo.RedirectStandardOutput = True
        proc.StartInfo.RedirectStandardError = True
        proc.StartInfo.FileName = "C:\Program Files (x86)\ImageMagick-6.6.1-Q16\convert.exe"

        proc.StartInfo.UseShellExecute = False
        proc.StartInfo.Arguments = String.Format("{0} {1}", Server.MapPath("~/logo/test.eps"), _
                                                 Server.MapPath("~/certificates/temp/test-1234.jpg"))
        proc.StartInfo.CreateNoWindow = True
        proc.Start()

I am able to run this code just fine on our development Win 2k3 server, but not on our production Win 2k3 Server. I get the error "System.ComponentModel.Win32Exception: Access is denied". The main between the two servers is that the production is 64-bit and runs Plesk to manage multiple domains. I've tried adding rights asp.net user to the ImageMagick directory. The PS Admin says that in the case of Plesk, it's the same account that I use to access the site in VS using FPE.

Does anyone know what I might do in order to allow this process to run on my production server?

Thanks,

Mike

回答1:

You need to make sure that the actual application pool identity is given the rights to start the application. I believe that plesk creates a specific user for each domain as you set it up on the server.

You can validate this using the IIS manager to see what application pool and identity it is in.

My guess is that you simply do not have the permissions granted for the correct user.