using VB to send messages to command line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FunkyChicken
    Sharp MM10 Lover
    • Oct 2004
    • 116

    #1

    using VB to send messages to command line

    hi there guys (+ girls)

    i would like to create a small program in vb that can send a string to the command line. for example i have a text box and a button, the user enters the desired command in the text box then they click the button. the string in the text box then gets out put to a new cmd window.

    for example

    they enter into the text box "ping www.google.co.uk"

    once i understand how this can be done i could use my program to create more sophisticated commands.

    i dont mind if i even have to ouput to the Start-Run dialog e.g.

    Code:
    cmd /C "ping www.google.co.uk"
    cheers in advance guys

    P.s. i do not expect you to simply tell me the code, but pointing me in the right direction where i can learn is prefered, cheers!!

    just so you guys known i aint being lazy, i have tried this

    Code:
    System.Diagnostics.Process.Start("cmd /C ping www.google.com")
    but it doesnt work

    gives the error:

    Code:
    A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
    cheers again
    Last edited by TheCotMan; February 13, 2006, 21:57. Reason: replies to self => power posting
  • converge
    No Values Voter
    • Oct 2001
    • 3322

    #2
    hrm.. been a few years.. but... check out the 'shell' command.
    if it gets me nowhere, I'll go there proud; and I'm gonna go there free.

    Comment

    • FunkyChicken
      Sharp MM10 Lover
      • Oct 2004
      • 116

      #3
      using VB to send messages to command line

      Code:
              Dim retval As Double
              retval = Shell("cmd /C ping www.google.com", vbNormalFocus)
      thanks very much converge, job done :-)

      Code:
      Shell("cmd /C ping www.google.com", vbNormalFocus)
      hell, thats all i need! cheers for that!

      P.s. basically, the reason for this is that i would like to create a very simple gui for the windows version of mplayer. I use mplayer but it comes onto windows as a cli command only, now i can create a simple GUI with option for things like full screen, frame dropping, subtitles, ect..

      cheers again



      ---------------------------------------------------------------------------------------------
      MESSAGE FOR BELOW, guess this is how i use the edit, sorry TheCotMan
      ---------------------------------------------------------------------------------------------
      Last edited by TheCotMan; February 13, 2006, 21:58. Reason: Power Posting, merged 2 posts into 1

      Comment

      • TheCotMan
        *****Retired *****
        • May 2004
        • 8857

        #4
        4 of Funky Chicken's posts were merges into 2 posts above.

        Copy of original posts (before merging) placed in /dev/null here.

        As per converge's request (see below) poop has been relocated (read, "removed") to /dev/null, leaving this conversation (minus poop) "fixed" and available.
        Last edited by TheCotMan; February 13, 2006, 22:04. Reason: merged above "power posting", relocated mean mod statements to /dev/null

        Comment

        • converge
          No Values Voter
          • Oct 2001
          • 3322

          #5
          hey mod, no pooping in the tech thread :p

          FunkyChicken, iirc I used it as a lazy tactic for making a GUI frontend to waglue back in the day. Basically have the lazy folks click through the dir boxes and radios; it simply fed the arguments to the cl binary. Other than that.. I think the last time I used it was in QBASIC. Not sure how sanctioned the tactic is, but its definately a quick fix.
          if it gets me nowhere, I'll go there proud; and I'm gonna go there free.

          Comment

          • GBHis
            /dev/uwindows
            • Jan 2006
            • 51

            #6
            VBScript can do such.
            Code:
            argument = wscript.arguments(0)
            newln = chr(13)
            Set objShell = CreateObject("WScript.Shell")
            objShell.Run "%comspec% /k " & argument
            objShell.SendKeys argument & newln
            Rem This will leave the cmd-prompt open. (so you can actually read the output.)
            put it in test.vbs and run it: "test.vbs hostname".
            Last edited by GBHis; February 15, 2006, 21:57. Reason: Removed some brain-dead code.

            Comment

            Working...