Is it possible to run an .exe from a web service hosted on an iis server?

0

I wanted to know if there is any way to run a .exe from a web service c #, I have the service already done and working but I would like to add the code that is below to generate a file .txt . But I do not know if it is possible or if it would just be enough to add the code to the service.

string command = "C:\Generar\Generador.exe " + FechaArchivo(fecha) + "";
ExecuteCommand(command);

static string ExecuteCommand(string _Command)
{
    //Indicamos que deseamos inicializar el proceso cmd.exe junto a un comando de arranque. 
    //(/C, le indicamos al proceso cmd que deseamos que cuando termine la tarea asignada se cierre el proceso).
    //Para mas informacion consulte la ayuda de la consola con cmd.exe /? 
    System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + _Command);
    // Indicamos que la salida del proceso se redireccione en un Stream
    procStartInfo.RedirectStandardOutput = true;
    procStartInfo.UseShellExecute = false;
    //Indica que el proceso no despliegue una pantalla negra (El proceso se ejecuta en background)
    procStartInfo.CreateNoWindow = false;
    //Inicializa el proceso
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo = procStartInfo;
    proc.Start();
    //Consigue la salida de la Consola(Stream) y devuelve una cadena de texto
    string result = proc.StandardOutput.ReadToEnd();
    return result;
    //Muestra en pantalla la salida del Comando
    //Console.WriteLine(result);
}
    
asked by Japh Sxas 30.01.2018 в 17:33
source

0 answers