Passing an input to a process

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mhmtzdmr@gmail.com

    #1

    Passing an input to a process

    Hi,

    I want to call a program and redirect the standart out to richtextbox
    control.


    I am using the procedure below.

    -------------------------------------------------------------------------------------------------------------------------
    Public Sub RunApp(ByVal myprocess As String, ByVal param As String,
    ByVal workingDir As String)
    Dim p As Process = New Process()
    Dim psi As New ProcessStartInf o()
    psi.FileName = myprocess
    psi.WorkingDire ctory = workingDir
    psi.Arguments = param
    psi.UseShellExe cute = False
    psi.CreateNoWin dow = True
    psi.RedirectSta ndardOutput = True
    psi.RedirectSta ndardError = True
    p.StartInfo = psi
    p.Start()

    myRichTextBox.t ext=p.StandardO utput.ReadToEnd ()

    End Sub
    -------------------------------------------------------------------------------------------------------------------------




    I call this procedure like this:
    RunApp("C:\Prog ram Files\DA Manager CLI\auhgmap", "-unit my_unit
    -refer", "")


    This calls "auhgmap" program and redirects its output to RichTextBox
    control.

    Everything works fine till here. But, I experience some problems when I
    call another similar program which accepts a password from me. My main
    program (vb.net) hangs. For example when I call my program from cmd.exe
    I see it is expecting a password and it does not generate any output
    unless I enter a password input to it.



    For example,

    C:\Program Files\DA Manager CLI>aufibre1 -unit Thunder_9500V -refer
    Password:
    ..
    ..
    .. // ----> After entering the password I can get the
    output
    ..
    ..
    C:\Program Files\DA Manager CLI>




    Question: How can I pass a parameter (the password) to another program
    using Process class?


    Thanks and regards.

  • mhmtzdmr@gmail.com

    #2
    Re: Passing an input to a process

    Any ideas???





    mhmtzdmr@gmail. com yazdi:
    Hi,
    >
    I want to call a program and redirect the standart out to richtextbox
    control.
    >
    >
    I am using the procedure below.
    >
    -------------------------------------------------------------------------------------------------------------------------
    Public Sub RunApp(ByVal myprocess As String, ByVal param As String,
    ByVal workingDir As String)
    Dim p As Process = New Process()
    Dim psi As New ProcessStartInf o()
    psi.FileName = myprocess
    psi.WorkingDire ctory = workingDir
    psi.Arguments = param
    psi.UseShellExe cute = False
    psi.CreateNoWin dow = True
    psi.RedirectSta ndardOutput = True
    psi.RedirectSta ndardError = True
    p.StartInfo = psi
    p.Start()
    >
    myRichTextBox.t ext=p.StandardO utput.ReadToEnd ()
    >
    End Sub
    -------------------------------------------------------------------------------------------------------------------------
    >
    >
    >
    >
    I call this procedure like this:
    RunApp("C:\Prog ram Files\DA Manager CLI\auhgmap", "-unit my_unit
    -refer", "")
    >
    >
    This calls "auhgmap" program and redirects its output to RichTextBox
    control.
    >
    Everything works fine till here. But, I experience some problems when I
    call another similar program which accepts a password from me. My main
    program (vb.net) hangs. For example when I call my program from cmd.exe
    I see it is expecting a password and it does not generate any output
    unless I enter a password input to it.
    >
    >
    >
    For example,
    >
    C:\Program Files\DA Manager CLI>aufibre1 -unit Thunder_9500V -refer
    Password:
    .
    .
    . // ----> After entering the password I can get the
    output
    .
    .
    C:\Program Files\DA Manager CLI>
    >
    >
    >
    >
    Question: How can I pass a parameter (the password) to another program
    using Process class?
    >
    >
    Thanks and regards.

    Comment

    Working...