473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 5633
Quick thought. Have the console app monitor a txt file using the
FileSystemWatcher 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*******@gmail.comwrote in message
news:67**********************************@f3g2000h sg.googlegroups.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.comwrote:
Quick thought. Have the console app monitor a txt file using the
FileSystemWatcher 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...@gmail.comwrote in message

news:67**********************************@f3g2000h sg.googlegroups.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*******@gmail.comwrote in message
news:f1**********************************@c23g2000 hsa.googlegroups.com...
On Jan 10, 7:38 pm, "CMoya" <m...@nospam.comwrote:
>Quick thought. Have the console app monitor a txt file using the
FileSystemWatcher 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...@gmail.comwrote in message

news:67**********************************@f3g2000 hsg.googlegroups.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...@gmail.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.diagnostics.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...@gmail.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(textbox1) and a button(button1) for these
demonstration:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim start_info As New ProcessStartInfo("cmd.exe", "/c dir")
start_info.UseShellExecute = False
start_info.CreateNoWindow = True
start_info.RedirectStandardOutput = True
start_info.RedirectStandardError = 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.StandardOutput()
' Display the results.
TextBox1.Text = std_out.ReadToEnd()
' Clean up.
std_out.Close()

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

Jan 11 '08 #6
"Paulers" <Su*******@gmail.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
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...
1
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...
8
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...
1
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...
6
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...
1
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...
8
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...
10
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...
12
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.