473,659 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Controlling a console application from another application.

Hello,

I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net? If so
could someone point me in the right direction. Thank you :)

Jan 11 '08 #1
6 5651
Quick thought. Have the console app monitor a txt file using the
FileSystemWatch er control. Pass (and return)commands to it via that file.
Just an idea.

The only other way would be via Remoting (the equivalent of old VB's ActiveX
Exe servers), which would allow you to call functions in the already running
process. Remoting is too tough to explain in a post. You can do a Google
search to find articles on it.

--
-C. Moya
http://www.cmoya.com

"Paulers" <Su*******@gmai l.comwrote in message
news:67******** *************** ***********@f3g 2000hsg.googleg roups.com...
Hello,

I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net? If so
could someone point me in the right direction. Thank you :)
Jan 11 '08 #2
On Jan 10, 7:38 pm, "CMoya" <m...@nospam.co mwrote:
Quick thought. Have the console app monitor a txt file using the
FileSystemWatch er control. Pass (and return)commands to it via that file.
Just an idea.

The only other way would be via Remoting (the equivalent of old VB's ActiveX
Exe servers), which would allow you to call functions in the already running
process. Remoting is too tough to explain in a post. You can do a Google
search to find articles on it.

--
-C. Moyahttp://www.cmoya.com

"Paulers" <SuperG...@gmai l.comwrote in message

news:67******** *************** ***********@f3g 2000hsg.googleg roups.com...
Hello,
I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net? If so
could someone point me in the right direction. Thank you :)
Thanks for the reply. The only issue is that the console application
is not mine. I just want to be able to control it from my application
and use it's output.
Jan 11 '08 #3
"Paulers" <Su*******@gmai l.comwrote in message
news:f1******** *************** ***********@c23 g2000hsa.google groups.com...
On Jan 10, 7:38 pm, "CMoya" <m...@nospam.co mwrote:
>Quick thought. Have the console app monitor a txt file using the
FileSystemWatc her control. Pass (and return)commands to it via that file.
Just an idea.

The only other way would be via Remoting (the equivalent of old VB's
ActiveX
Exe servers), which would allow you to call functions in the already
running
process. Remoting is too tough to explain in a post. You can do a
Google
search to find articles on it.

--
-C. Moyahttp://www.cmoya.com

"Paulers" <SuperG...@gmai l.comwrote in message

news:67******* *************** ************@f3 g2000hsg.google groups.com...
Hello,
I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net? If so
could someone point me in the right direction. Thank you :)

Thanks for the reply. The only issue is that the console application
is not mine. I just want to be able to control it from my application
and use it's output.
Take a look at input/output redirection. Before coding this, you can test
redirection from the command line.

Mike.
Jan 11 '08 #4
On Jan 10, 7:31*pm, Paulers <SuperG...@gmai l.comwrote:
Hello,

I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net? If so
could someone point me in the right direction. Thank you :)
You can use system.diagnost ics.process to start the app, and then
redirect it's input and output to streams in your process. Then you
can read and write to it.

--
Tom Shelton
Jan 11 '08 #5
On Jan 11, 4:31 am, Paulers <SuperG...@gmai l.comwrote:
Hello,

I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net? If so
could someone point me in the right direction. Thank you :)
You can redirect command prompt's output to an Win32 app's object
within your project:

Here is a sample returns "dir" command prompt result into a textbox:

Place a textbox(textbox 1) and a button(button1) for these
demonstration:

Public Class Form1

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
Dim start_info As New ProcessStartInf o("cmd.exe", "/c dir")
start_info.UseS hellExecute = False
start_info.Crea teNoWindow = True
start_info.Redi rectStandardOut put = True
start_info.Redi rectStandardErr or = True

' Make the process and set its start information.
Dim proc As New Process()
proc.StartInfo = start_info

' Start the process.
proc.Start()

' Attach to stdout and stderr.
Dim std_out As IO.StreamReader = proc.StandardOu tput()
' Display the results.
TextBox1.Text = std_out.ReadToE nd()
' Clean up.
std_out.Close()

proc.Close()
End Sub
End Class
Hope this helps.

Jan 11 '08 #6
"Paulers" <Su*******@gmai l.comschrieb:
I am trying to manipulate a console based application from another
application for example I need to launch the console application,
provide it input and take the output from the console application and
use it within my application. Is this possible with vb.net?
Yes, that's possible:

<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole .zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Jan 12 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1394
by: Isaac Raway | last post by:
I want to start a console application on a Windows 2000 machine and control it's I/O. pexpect is exactly what I want, but it doesn't work on Windows. Does anyone know of another module similar to pexpect that does work on windows?
1
5377
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
8
3214
by: Andrey Mosienko | last post by:
We are using PostgreSQL about two years beginning from version 7.0. I have one question about starting postmaster: Is there way to detach it from the controlling terminal under FreeBSD? My situation: I start postmaster manually: su pgsql -c "/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start" Log:
1
2298
by: Doug Perkes | last post by:
I have a legacy console application that I need to control with a c# desktop application. The main functionality i need is the following: Send strings Read strings at specific locations Send function keys (F3, F4, etc) I have used the code from Extended Functionality for System.Console
6
3232
by: Mark Allison | last post by:
Hi, I have an application that I want to be to run in Console mode and GUI mode. If no params are entered, I want the GUI fired up, if params are entered, then go into console mode. I believe I have all the code set up to do this, however when I issue a Console.WriteLine instruction, nothing gets written to the console. In fact, the command prompt comes back before the program has finished executing. What do I need to do?
1
2128
by: cplusplusstudent | last post by:
Hello I am a new C++ programmer and am working with the Visual C++ studio. I am attempting to create a simple console application for myself but I fin that neither of the introductory C++ books I own tell me how to clear the console screen or change the font color. Is there some way to do this that could b understood by a novice programmer? Here are the three things I would like to do: Control the size of the console screen when the...
8
2175
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
10
6331
by: Stephany Young | last post by:
When one uses the System.Diagnostics.Process.Start method to launch a common or garden Console application, one can set the WindowStyle property of the StartInfo object to ProcessWindowStyle.Hidden so that the window for the Console application is not visible. However, when using some of the 'advanced' properties of the StartInfo object, like Username, Password and Domain, the WindowsStyle property of the StartInfo object is ignored....
12
6526
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow combination to hide the console window at launch time. The application (for legacy reasons) hangs around by waiting on an old- fashioned Console.ReadLine() statement.
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.