c# – how I can run any .exe file through WebService – Education Career Blog

how I can run any .exe file through WebService that I build ?

thank’s in advance

,

Take a look at the System.Diagnostics.Process class.

,

You can try this.

using System.Diagnostics;

class Program
{
    static void Main()
    {
        Process.Start("example.exe");
    }
}

,

I think you want to be able to send a exe file to your webservice and than execute that?

I would advice to following sequence.

  1. Recieve the file and write it to a temporary directory.
    • Optionally scan the file with a anti-virus scanner. (Depending on the level of trust of your webservice)
    • Use Process.Start to start the temporary file and wait for it to stop running (perhaps supply a parameter to wait for exit or not)
    • Delete the temporary file.
    • Report back the result of the execution (if it’s console application you could even report back the text printed by the application).

Leave a Comment