Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an command-prompt exe which take argument, perform its functions and display the output in command-prompt .

i need to call the command-prompt file from vb.net passing the argument without showing the dos window, and get the return values directed to vb textbox.

anyone ideas?
Posted

I use this in an app where the streams are written to a textbox using a delegate...
Public Shared Function launch_hProccess(ByVal myfile As String, Optional ByVal Args As String = Nothing, Optional ByVal wait As Boolean = True, Optional ByVal background As Boolean = True) As Integer
        Try
            cmd_Process = New Process 'new object
            With cmd_Process.StartInfo
                .FileName = myfile
                .Arguments = Args
                .CreateNoWindow = True
                .UseShellExecute = False
                .ErrorDialog = False
                .RedirectStandardOutput = True
                .RedirectStandardError = True
            End With
            cmd_Process.Start()
            launch_hProccess = cmd_Process.Id
            cmd_OutputThread = New Thread(AddressOf cmd_so)
            cmd_OutputThread.IsBackground = background 'default=true
            cmd_OutputThread.Start()
            cmd_ErrorThread = New Thread(AddressOf cmd_eso)
            cmd_ErrorThread.IsBackground = background 'default=true
            cmd_ErrorThread.Start()
            If wait Then cmd_Process.WaitForExit()
        Catch ex As Exception
            log_write(ex.Message & " in launch_hProcess...", txtC.status)
        End Try
    End Function
 
Share this answer
 
Look at the Process.StandardOutput property[^] - there is an example there.
You may find it helpful to set the Process.StartInfo.CreateNoWindow property[^] to true as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900