#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    245
    Rep Power
    12

    How do I capture all of the text in a DOS window


    Visual Basic 5.0

    Below is a VB program that call a batch file to be run in DOS window.

    How do I capture all of the text in a DOS window and store it in
    a Visual Basic string variable ?

    =================================
    Code:
    Private Sub Start_IPsec_Click(Index As Integer)
        Dim Program_Name As String
        
        Program_Name = "C:\ipsecpol\ping.bat"
        Call Run_DOS_Program(Program_Name)
        Text1.Text = "The IPsec program has started."
    
    End Sub
    
    Private Sub Run_DOS_Program(Program_Name)
        Dim MyAppID, ReturnValue
        
        ' AppActivate can also use the return value of the Shell function.
        MyAppID = Shell(Program_Name, 1)   ' Run DOS program
    End Sub
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2003
    Posts
    1,152
    Rep Power
    13
    This class capture the outpus of a DOS application via API functions, redirecting the stdOutput pipe and the stdErr pipe of a DOS application from the screen to the pipe that this class create.

    You can use this with any DOS application. To use it with a DOS command, type the following into text box:

    cmd.exe /c [command], e.g.,

    cmd.exe /c dir

    Download it:http://www.freevbcode.com/source/DOSOutputs.zip
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    245
    Rep Power
    12

    reply


    Hi Cleverpig. Thank you for your help.

    I got the program, and when I put in the command
    "cmd.exe /c dir" and press the exceute button, it showed a
    directory listing not in C:\ but a directory listing of
    where the visual basic program is at - that is the one that capture a batch output and put it in a text box.

    I did tried this "cmd.exe /c/ipsec/ dir" and the error message is
    '/ipsec' is not recognized as an internal or external command,
    operable program or batch file.

    I did tried this "cmd.exe /c/ipsec dir" and the error message is
    '/ipsec' is not recognized as an internal or external command,
    operable program or batch file.
    =====================================

    In the DOSOutputs class I had to comment out these codes so that the program could run.

    ' MultiUse = -1 'True
    ' Persistable = 0 'NotPersistable
    ' DataBindingBehavior = 0 'vbNone
    ' DataSourceBehavior = 0 'vbNone
    ' MTSTransactionMode = 0 'NotAnMTSObject
    'End
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    2
    Rep Power
    0
    cmd.exe /c dir c:\

IMN logo majestic logo threadwatch logo seochat tools logo