Home All Groups Group Topic Archive Search About

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

Author
26 Nov 2006 3:53 AM
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

Author
26 Nov 2006 12:29 PM
Herfried K. Wagner [MVP]
"tsung-yu" <tsung***@hotmail.com> schrieb:
> 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?

See:

<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://classicvb.org/petition/>
Author
26 Nov 2006 12:34 PM
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


Show quoteHide quote
"tsung-yu" <tsung***@hotmail.com> wrote in message
news:ePKX55QEHHA.3576@TK2MSFTNGP03.phx.gbl...
>
>
>
> 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
>
>