How do you call a Console application from ASP.NET and get the results??
Sep 7, 2004 • Chris Pietschmann • ASP.NET • Visual BasicHere is a VB.NET version of a C# example that I found to do just that. It’s really simple to do.
<%@ Page Language="vb" %>
<%@ Import Namespace="System.Diagnostics" %>
<%
''Get a file name relative to the current Web app.
Dim file As String = Server.MapPath("Program.exe")
Dim info As ProcessStartInfo = new ProcessStartInfo(file, "/arguments")
''Redirect output so we can read it.
info.RedirectStandardOutput = true
''To redirect, we must not use shell execute.
info.UseShellExecute = false
''Create and execute the process.
Dim p As Process = Process.Start(info) p.Start()
''Send whatever was returned through the output to the client.
Response.Write(Replace(Replace(p.StandardOutput.ReadToEnd(), vbCrLf, " "), " ", " "))
%>

Chris Pietschmann
DevOps & AI Architect | Microsoft MVP | HashiCorp Ambassador | MCT | Developer | Author
I am a DevOps & AI Architect, developer, trainer and author. I have nearly 25 years of experience in the Software Development industry that includes working as a Consultant and Trainer in a wide array of different industries.