Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact

NAVIGATION - SEARCH

How do you call a Console application from ASP.NET and get the results??

Here 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, " "), " ", " "))
%>

blog comments powered by Disqus