Results 1 to 17 of 17

Thread: Running a DOS Command WITHOUT the Command window appearing

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2004
    Posts
    45

    Running a DOS Command WITHOUT the Command window appearing

    Hi,

    I want to run a DOS command from my Visual Basic program - and I can do that fine, but I want to do it without the Command Window popping up. Is there a way to do this?? because if the command window pops up it makes my app look very scruffy.

    Robin

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586
    What dos commands are you trying to run? Chances are there is a windows equivalent command that you can run instead so that you dont get the command prompt.

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2004
    Posts
    45
    I'm trying to run the ping command.

    I need to get the output (I dont care about the time - I just need to know if it worked or failed) so I was thinking of doing ping 192.168.0.1 > ping.txt or summat like that.

    Thanks

    Robin

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2004
    Posts
    45
    thanks for your help but I've just found a way to do ping without using the DOS Command prompt.

    Thanks

    RObin

  5. #5
    New Member
    Join Date
    Dec 2003
    Location
    india
    Posts
    5
    Hi rob,

    could you pls tell me how do you ping without using the dos command.

    thanx..

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2004
    Posts
    45

  7. #7
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959
    VB Code:
    1. Shell "cmd /k ping 127.0.0.1 >e:\ping.txt ", vbHide
    But cmd is still going to be loaded as a process.

  8. #8

    Thread Starter
    Member
    Join Date
    Mar 2004
    Posts
    45
    Hadn't noticed that! Thanks for telling me - but it works fine and I cant see the command window!

    Thanks

    Robin

  9. #9
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961
    FYI I hear WinXP SP2 turns off response to a PING request so it seems PING is becoming less useful thanks to M$.

  10. #10
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Running a DOS Command WITHOUT the Command window appearing

    Quote Originally Posted by Jmacp View Post
    VB Code:
    1. Shell "cmd /k ping 127.0.0.1 >e:\ping.txt ", vbHide
    But cmd is still going to be loaded as a process.
    I was searching how to do this for quite some time... I was about to create a thread too..
    Thanks a lot...

    It'd be great if you could elaborate what /k is.
    Also what does the > before the Location of the File mean?
    Last edited by TheThinker; Dec 5th, 2012 at 11:15 AM.

  11. #11
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Running a DOS Command WITHOUT the Command window appearing

    >elaborate what /k is
    Open a Command (cmp) prompt window; type in cmd /? and press Return; it will provide help for the options for the cmd command

    I suggest it may be preferrable to use the /C option, otherwise you may end up with an invisible Command prompt window/ process (each time you do the call) and that (all of them) will remain until the computer is restarted.

  12. #12
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Running a DOS Command WITHOUT the Command window appearing

    Quote Originally Posted by TheThinker View Post
    Also what does the > before the Location of the File mean?
    It's called Redirection.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  13. #13
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Running a DOS Command WITHOUT the Command window appearing

    Quote Originally Posted by Magic Ink View Post
    Open a Command (cmp) prompt window; type in cmd /? and press Return; it will provide help for the options for the cmd command

    I suggest it may be preferrable to use the /C option, otherwise you may end up with an invisible Command prompt window/ process (each time you do the call) and that (all of them) will remain until the computer is restarted.
    Quote Originally Posted by Bonnie West View Post
    It's called Redirection.
    So If i want to output the file to a folder tat doesn't exist, I'll have to create the Folder via MD/MKDIR
    Right?
    Thanks a lot.

  14. #14
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Running a DOS Command WITHOUT the Command window appearing

    That would be MD /MKDIR; note the space.
    However vb has the MkDir Statement so you do not need to do it via the Command (cmd) window.

  15. #15
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Running a DOS Command WITHOUT the Command window appearing

    Quote Originally Posted by Magic Ink View Post
    That would be MD /MKDIR; note the space.
    Doesn't MD and MKDIR refer to the same command?
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  16. #16
    Member
    Join Date
    Oct 2012
    Posts
    61

    Re: Running a DOS Command WITHOUT the Command window appearing

    Quote Originally Posted by Bonnie West View Post
    Doesn't MD and MKDIR refer to the same command?
    Yes it does... Which is why I made use of the /

  17. #17
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Running a DOS Command WITHOUT the Command window appearing

    Sorry I misunderstood - you meant 'MD or MkDir' of course.

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