CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2011
    Posts
    2

    executing shell commands from string

    how can i execute a shell command from a string
    what im trying todo is this

    shell("cd", StringName)

    the string comes from a user entered textbox

    StringName = Textbox.text

    how can i get this to work?

  2. #2
    Join Date
    Sep 2010
    Posts
    23

    Re: executing shell commands from string

    You write the complete command to a .bat file, and use shell("batfile.bat")

  3. #3
    Join Date
    Feb 2011
    Posts
    2

    Re: executing shell commands from string

    Quote Originally Posted by mavy-online View Post
    You write the complete command to a .bat file, and use shell("batfile.bat")
    i have explored this option but how do i pass along the directory the user entered in the text box?
    i am using visual studio 2010

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: executing shell commands from string

    what im trying todo is this
    Doesn't make any sense. You want a shell to CD?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Sep 2010
    Posts
    23

    Re: executing shell commands from string

    Quote Originally Posted by cm0002 View Post
    i have explored this option but how do i pass along the directory the user entered in the text box?
    i am using visual studio 2010
    You concatenate your command of choice with everything in the textbox.

    dim batfile as string = "cd " & textBox1.Text

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: executing shell commands from string

    Of course there is no point using shell at all if the goal is to change the directory as this can easily be done within the program.
    Always use [code][/code] tags when posting code.

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

Featured