Solved

Launch an exe from ASP.Net

Posted on 2009-05-18
2
581 Views
Last Modified: 2012-05-07
I've been banging my head against the wall for a couple days now on this issue.  My ultimate goal is to launch a ghostscript executable from a WCF service.  My troubles began soon as I moved this create process under IIS.  The personal web server in Visual Studio worked without a hitch.  I'm also able to launch this from WinForms without any issues.  But the security around IIS is a tough nut to crack.  This is for a good reason of course.

I have tried many different approaches, including impersonating, all kinds of different security tweaks, none of which have worked.  I have moved the create process code into a code behind asp.net page in order to deal with IIS security directly.  I am impersonating a fully authorized domain account in Web.Config.  My App Pool identity is set to this same activity directory account.  The exe is sitting in the bin folder of the asp.net site, I have given the folders & site full permissions.  Is there anything left to do?  The below code hangs on the WaitForExit() method but works fine from Windows App.

If all else fails this could be moved into a Windows Service possibly, the security is probably not as limiting as IIS.  Also I'm learning that WCF can be self-hosted rather than using IIS.  

Does anyone have experience with this issue and have recommendations?  
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(GhostScriptPath);

        startInfo.UseShellExecute = false;

        startInfo.RedirectStandardInput = true;

        startInfo.RedirectStandardOutput = true;

        startInfo.RedirectStandardError = true;

        startInfo.WorkingDirectory = @"c:\aTemp";

        startInfo.WindowStyle = ProcessWindowStyle.Hidden;

        startInfo.Arguments = " -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=" + Convert.ToString(1) + " -sDEVICE=ljet4 -sOutputFile=\"\\\\spool\\" + @"\\CONFP01\CON-2-M4345-01" + "\" \"" + pathAndFileName + "\"";

        

        // Start the process

        System.Diagnostics.Process proc = System.Diagnostics.Process.Start(startInfo);

        proc.WaitForExit(); //Hangs on this line of code

        proc.Close();

Open in new window

0
Comment
Question by:BenLuckhardt
2 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24416996
Have You Tried P/Invoke with ShellExecute and WaitForSingleObject? Might give you more options.

Also you can write ISAPI Plugins for IIS which might work aswell.
0
 

Accepted Solution

by:
edenrockstar earned 500 total points
ID: 24490140
Further head banging has helped me narrow down a couple solutions.  

+ WCF and a background worker thread for handling the long delay
+ WCF + MSMQ
+ Plain ole' MSMQ and using a console app to initialize the ghostscript executable.  


0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I had to do a bit of research to find the answer to this question so I thought I'd share my results.  Due to our outdated mainframe systems, we need to downgrade IE9 to IE8 in order to stay compatible.  We also needed to downgrade Java.  In order to…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now