Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



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

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: General
Posted by crpietschmann on Tuesday, September 07, 2004 5:32 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Related posts

Comments

Sundar

Thursday, March 23, 2006 4:45 AM

Sundar

I have a console app, that copy's the contents of a excel file into clipboard, and it is running on the webservber, my code does not execute and it hangs Frown

i have added microsoft excel 11.0 object library. from COM components

private object m_objOpt = System.Reflection.Missing.Value;

Excel.Application objLExcel; //the Excel object
Excel.Workbooks colLBooks; //the Workbooks collection of the Excel object
Excel._Workbook objLBook; //the active Workbook object
Excel.Sheets colLSheets; //the sheets collection of the workbook
object objLMissing; //for optional argument
objLExcel = new Excel.Application();
//object used for optional argument
objLMissing = System.Reflection.Missing.Value;
//gets the collection of workbooks of the excel
colLBooks = (Excel.Workbooks)objLExcel.Workbooks;
objLBook = null;
objLBook = colLBooks.Open(@"c:\test.xls" ,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing,objLMissing);
Excel._Worksheet objLSheet = null;
colLSheets = (Excel.Sheets)objLBook.Worksheets;
objLSheet = (Excel._Worksheet)(colLSheets.get_Item(1));
objLSheet.get_Range("a1","b1").Copy(m_objOpt);
IDataObject data = Clipboard.GetDataObject();
Image image = (Image)data.GetData(DataFormats.Bitmap,true);

labhesh

Monday, August 07, 2006 3:53 AM

labhesh

I have problem with calling command line argument of server process from client side asp.net.
How this can be achieved.
i am using dotnet 2005 version.

I user System Process for this.
Is there any simple or direct solution.
There might be concurrent user also for the same application.

Comments are closed

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann