Invoking a command line .exe program

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

Hi,

I have a simple .exe application that I need to invoke from my C#
application. I need to send it two strings and then get the result back.

Can anyone advise me on how this is done?

Also, I'm currently using a windows forms application but I would like to
use an ASP.net appliocation to invoke the .exe file in the future. Is this
possible and will it cause any complications?

Thanks everyone

Simon
 
Answer to the first part of the question: take a look at
System.Diagnostics.Process.

Christian
 
Hi,

Did you try System.Diagnostics.Process.Start()?

Hi,

I have a simple .exe application that I need to invoke from my C#
application. I need to send it two strings and then get the result back.

Can anyone advise me on how this is done?

Also, I'm currently using a windows forms application but I would like to
use an ASP.net appliocation to invoke the .exe file in the future. Is this
possible and will it cause any complications?

Thanks everyone

Simon
 
Hi,

simplest thing would be using the below line of code

System.Diagnostics.Process.Start(@"yourpath to your
application\WindApp.exe");

HTH
irfan
 
Simon,

ASP.NET application can invoke an ece in the same way as Windows form one.
The only difference is that you will need to grant "run executable" rights
to account aspnet runs under.

Eliyahu
 
The other responders gave you the answer.

I have a question: did you write the command line app? If so, can it be
rewritten in .NET?
That would give you some better answers when it comes to using resources,
especially if you plan to run this in a server.

Running it from a web page will work, but it won't be terribly scalable.

--- Nick
 
Giving the ASPNET account "run executable" rights is a terrible security
hole. I would strongly suggest that you look for another solution to your
problem, perhaps rewriting the executable as a windows service (or wrapping
it on one) and having the ASP application set certain conditions (such as a
flag in the DB) that cause the code currently in the executable to run.

Eric
 
Back
Top