views:

202

answers:

1

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  A: 

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.

Mitchel Sellers
That did the trick, I found that there is an IWAM_plesk user that is the identity for the domain. Once we added permissions to that user then the command executed. Now I'm just running into file permissions errors dealing with the files we are trying to convert, as well as access to Ghostscript, which IM uses. I wish that someone had just written a .NET library that did the same thing :/. Thanks, though.
Mike C
It is always a pain to call an .exe from a web application. if it isn't something that you need "real-time", you could create a windows service that could do the processing for you, it would have a more standard permission set available to you and takes you out of the web context.
Mitchel Sellers