Share via

Control application

kaveh rahimi 66 Reputation points
2021-08-15T05:39:06.407+00:00

Hi ,I want to control the input and output of "I2C Tools" from a visual basic program. I use the following code and receive the errors:
BC30205 and BC30002
Module Module1

Sub Main()
    Dim myProcess As Process = New Process()
    Dim s As String myProcess.StartInfo.FileName = "cmd.exe"

myProcess.StartInfo.UseShellExecute = False
    myProcess.StartInfo.CreateNoWindow = True
    myProcess.StartInfo.RedirectStandardInput = True
    myProcess.StartInfo.RedirectStandardOutput = True
    myProcess.StartInfo.RedirectStandardError = True
    myProcess.Start()

    Dim sIn As StreamWriter = myProcess.StandardInput
    Dim sOut As StreamReader = myProcess.StandardOutput
    Dim sErr As StreamReader = myProcess.StandardError

    sIn.AutoFlush = True
    sIn.Write("dir c:\windows\system32\*.com" & System.Environment.NewLine)
    sIn.Write("exit" & System.Environment.NewLine)
    s = sOut.ReadToEnd()

    If Not myProcess.HasExited Then
        myProcess.Kill()
    End If


End Sub

End Module
How can I resolve this errors?
Please help
Thanks

Developer technologies | VB

1 answer

Sort by: Most helpful
  1. Castorix31 91,876 Reputation points
    2021-08-15T08:48:18.673+00:00

    You have put 2 instructions on the same line :

    Dim s As String myProcess.StartInfo.FileName = "cmd.exe"
    

    =>

    Dim s As String 
    myProcess.StartInfo.FileName = "cmd.exe"
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.