Hooking a dos program and controlling it from VB.NET

Squeebee

New member
Joined
Aug 15, 2003
Messages
1
Hi All;

I am trying to build a better interface for a dos SQL client, and rather than re-invent the wheel I thought I would just try to hook into the DOS program and lay my features on top of it.

Here is my code so far:
Code:
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim mysql As Process = New Process
        mysql.StartInfo.FileName = "d:\mysql\bin\mysql"
        mysql.StartInfo.Arguments = "-u root -p"
        mysql.StartInfo.UseShellExecute = False
        mysql.StartInfo.CreateNoWindow = True
        mysql.StartInfo.RedirectStandardError = True
        mysql.StartInfo.RedirectStandardInput = True
        mysql.StartInfo.RedirectStandardOutput = True
        mysql.Start()

        Dim mysqlin As System.IO.StreamWriter = mysql.StandardInput
        Dim mysqlout As System.IO.StreamReader = mysql.StandardOutput
        Dim myerror As System.IO.StreamReader = mysql.StandardError
        mysqlin.AutoFlush = True

        mysqlin.Write("mypassword")

        output.Text = mysqlout.ReadToEnd

        MsgBox(mysql.Responding)

Problem is that nothing happens. If I comment out everything but the useshellexecute line (except the start() ) then I get a shell with the client. Anyhow, mysqlout is a richtextbox. For stage one I just want to get the DOS app running inside a richtextbox.

Any help would be greatly appreciated.
 
well im having the same prop I think this has somethig to do with mysql I get the following error

-- MySQL dump 9.09
--
-- Host: localhost Database: ddf
---------------------------------------------------------
-- Server version 4.0.15-nt
c:\mysql\bin\mysqldump.exe: Cant get CREATE TABLE for table `>` (Cant find file: .\ddf\>.frm (errno: 22))


Im trying to backup a mysql database but notting works this is the code i got so far

Code:
 Dim mysql_1 As New Process()
        mysql_1.StartInfo.WorkingDirectory = "c:\mysql\bin"
        mysql_1.StartInfo.FileName = "c:\mysql\bin\mysqldump.exe"
        mysql_1.StartInfo.Arguments = "ddf > C:\mysql\bin\test.sql"
        mysql_1.StartInfo.UseShellExecute = False

        mysql_1.StartInfo.CreateNoWindow = False
        mysql_1.StartInfo.RedirectStandardError = True
        mysql_1.StartInfo.RedirectStandardInput = True
        mysql_1.StartInfo.RedirectStandardOutput = True

        mysql_1.Start()
 mysql_1.StandardInput
        Dim mysqlout As System.IO.StreamReader = mysql_1.StandardOutput
        Dim myerror As System.IO.StreamReader = mysql_1.StandardError
                       TextBox1.Text = mysqlout.ReadToEnd & " " & myerror.ReadToEnd


This is the same code as you are using but i get a reading from the streamer

Any help would be good

thx
 
Back
Top