Results 1 to 3 of 3

Thread: call prompt

  1. #1

    Thread Starter
    Lively Member smartrajesh's Avatar
    Join Date
    Feb 2005
    Posts
    94

    Question call prompt

    how can call command prompt from vb.
    example:
    if u run a command "dir" it will give filelist to u. right. like this i have to give this command from my vb appl. the result will be stored in listbox. without using drivelistbox, or director or some else...

    bye..
    Regards
    Rajesh
    ^ ^
    (*)(*)

    (((()))

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: call prompt

    TextBox1 stores the command eg dir
    TextBox2 gives the results

    Code:
    Imports System.IO
    Imports System.Diagnostics
    'add this to the button click event
            Dim p As Process
            p = New Process()
            p.StartInfo.FileName = "cmd.exe"
            p.StartInfo.UseShellExecute = False
            p.StartInfo.RedirectStandardInput = True
            p.StartInfo.RedirectStandardOutput = True
            p.StartInfo.CreateNoWindow = True
            p.Start()
            p.StandardInput.WriteLine(TextBox1.Text)
            p.StandardInput.WriteLine("Exit")
            TextBox2.Text = p.StandardOutput.ReadToEnd()
            p.Close()

  3. #3
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: call prompt

    Dead Eyes showed hoe to use the CommadLine.

    However if all you want is the Files in a Directory you should use the Directory Class:

    Code:
    string [] files = Directory.GetFiles(textBox1.Text);
    foreach (string file in files)
    {
        listBox1.Items.Add(file);
    }
    with textbox1 containing the Path to your folder!

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width