Run program in certain folder in IIS

Asked

Viewed 183 times

2

I would like to know how to run an exe or jar program in a certain IIS folder, through the code c# . net core. It would have to be a synchronous call, that is when c# performs the call from the jar or exe or bat has to wait for the processing to continue.

  • You want to run this every time the system starts or through some specific event?

  • For example when you click a button, it calls the controller that will call my service that will execute the bat or jar by passing a parameter.

1 answer

2


Use the Process.

 using System.Diagnostics;
 Process.Start("teste.exe");

Wait for the process to close.

using System.Diagnostics;
...
Process process = new Process();
// Configure o processo usando as propriedades do StartInfo.
process.StartInfo.FileName = "teste.exe";
process.StartInfo.Arguments = "-n";
process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
process.Start();
process.WaitForExit();// espera o processo encerrar

Browser other questions tagged

You are not signed in. Login or sign up in order to post.