0

I have an exe on a server that runs at a scheduled time each day, but i also want to provide a way to start the exe manually throughout the day if needed.

I have tried the following code behind in an ASP.Net page:

System.Diagnostics.Process theProcess = new System.Diagnostics.Process();
theProcess.StartInfo.FileName = "C:\\inetpub\\wwwroot\\MyWebsite\\MyProcessor.exe";
theProcess.Start();

But when i click the button to which this code is assigned to, nothing happens, no errors, no process on the server. Nothing. The web browser just sits there trying to reload the page.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Jonathan Smith
  • 2,390
  • 1
  • 34
  • 60
  • Does it work if you run it locally? Have you debugged the code? Try to surround the code with try/catch to catch and/or log exceptions that are being thrown. Under what account does the respective application pool run? Does it have access to the executable? – Andre Loker Mar 03 '12 at 09:39
  • To run a exe from ASP .Net is possible, but under certain conditions. Also it helps to know the versions of IIS and ASP .Net and if you have full access to the server – Adrian Iftode Mar 03 '12 at 09:42
  • Yes, the app runs locally with no problems. It has been running as scheduled task for weeks now. In terms of the account and permissions, it has exactly the same permissions as the rest of the website files, that work fine. – Jonathan Smith Mar 03 '12 at 09:42
  • Ye,s i have full access to the server, it is a hosted virtual private server running windows 2008 – Jonathan Smith Mar 03 '12 at 09:43
  • What i dont understand is if there were any problems, i would get a web exception. But the page is still trying to refresh. It has been like this for around 15 minutes. – Jonathan Smith Mar 03 '12 at 09:44
  • see this answer http://stackoverflow.com/questions/8061362/starting-a-process-from-asp-net-why-does-the-process-immediately-die/8061534#8061534 – Adrian Iftode Mar 03 '12 at 09:50
  • Code now looks like this: try { writelog("Button Clicked"); System.Diagnostics.Process theProcess = new System.Diagnostics.Process(); theProcess.StartInfo.FileName = "C:\\inetpub\\wwwroot\\MoreFinance\\PaymentProcessor.exe"; theProcess.Start(); writelog("Process started"); } catch (Exception myExp) { writelog(myExp.Message); } but the log only shows "Button clicked" and no errors are reported. – Jonathan Smith Mar 03 '12 at 09:58
  • I dont understand, why the vote down? – Jonathan Smith Mar 04 '12 at 09:20
  • I don't know why the downvote, but you should edit your question to contain the code instead of putting it in the comment. – John Saunders Mar 04 '12 at 15:33

1 Answers1

0

If You have access to that server, then instead of starting that application you could have it running all the time and check for some flag in DB to execute Desired action... flag could be changed by button on your web application, That will isolate your application from IIS.