How to run and communicate a DOS program file in a VB.NET program?

T

tsung-yu

Hello any expert,

I has a vb.net program.
For user requirement, I need to run and communicate an old DOS execution
file.
But, how to run and communicate a DOS program in a VB.NET program?
Should I use the Process or Console class? How to do that?

For example,
If this DOS program name as "pick.exe".

In DOS SHELL, user run the pick.exe then type "command1" and wait to
response1

message.
type "command2" and .
When user receives the response1 message then type "command2" and wait to

receive response2 message, later, user closes the DOS SHELL window.

welcome to pick.exe v1.23
-------------------------
command1
..........
response1 message
command2
..........
response2 message


Thank you very much.
Joe
 
O

OHM

Here is an example, of how to write and get input from the console program.

Module Module1

Sub Main()

Dim myNum As Double

Do While getNumber(myNum)

myNum *= 10
Console.WriteLine("That number multiplied by 10 = " &
myNum.ToString)

Loop

Console.WriteLine("Thank you for using the calculator!")
Console.ReadLine()

End Sub

Function getNumber(ByRef myNum As Double) As Boolean
Dim myVal As String
Console.WriteLine("Please enter a value between 1 and 10 ")
myVal = Console.ReadLine
If Not IsNumeric(myVal) Then
Console.WriteLine("That was NOT a number !")
Return False
Else
myNum = CType(myVal, Double)
Return True
End If

End Function

End Module

End Module
 
A

aaron.kempf

you can't communicate with DOS; DOS is only on Windows 95/98/Me and
none of those support VB 2005.

-Aaron
 
C

Chris Dunaway

you can't communicate with DOS; DOS is only on Windows 95/98/Me and
none of those support VB 2005.

While DOS may not exist any more, it is fairly simple to communicate
with a *console* application using the Process class and by redirecting
standard input and output as Herfried and OHM suggested.

And .Net 2.0 apps will run on Win 98, Win Me and higher. Only Win 95
is not supported. Taken from Microsoft.com:

Supported Operating Systems: Windows 2000 Service Pack 3; Windows 98;
Windows 98 Second Edition; Windows ME; Windows Server 2003; Windows XP
Service Pack 2

Chris
 
L

Larry Linson

of course, VB 2002, 2003 and 2005 are not supported on _VISTA_ right?

I heard that VB is going away

Larry Linson, Jr
 
A

aaron.kempf

and I want a reference for that; I dont believe that .NET 2.0 supports
windows 98

you sure can't install VB 2005 Express Edition on Windows 98 can you?

-Aaron
 
C

Chris Dunaway

D

dbahooker

so sorry this is what was hanging me up
o Windows Installer 3.0 (except for Windows 98/ME, which require
Windows Installer 2.0 or later). Windows Installer 3.1 or later is
recommended.

well if 3.0 isn't a requirement then why do they make me install it
before installing SQL 2005?

these ****ers need to learn how to SIMPLIFY


if they had just done as they said; and discontinued the 9x line with
the release of Windows 2000-- then maybe things wouldn't be sooo
complex

it's just laughable now
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top