Results 1 to 5 of 5

Thread: help with shell calls

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    2

    help with shell calls

    I am trying to open a dos window using a shell call. I can get the dos prompt to come up but it will only stay open for about a second and then it closes. I am using the following code:

    Shell("c:\windows\ping.exe", vbNormalFocus)

    Is this correct? I want to pass a ping command to the app and wait for the results.

    Thanks for the help
    At some point in time everyone exceeds the expectations places on him or her. The question that will judge us all is, “How will you live once that attention is gone?”

  2. #2
    Lively Member
    Join Date
    Nov 2000
    Location
    NC
    Posts
    66
    I haven't tried this but it should work to use the shell command to open the console window (DOS prompt) then send the ping command to the screen along with a carriage return line feed (for Enter) then get the result from the screen.

    Even if you run ping from start run it closes the console window down as quick as the ping returns a result.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    2
    That is another question. How do I get that up? It tells me that the path is not found when I try and open command.com or just a shortcut to the dos prompt. I can open it with out the VB

    Thanks
    At some point in time everyone exceeds the expectations places on him or her. The question that will judge us all is, “How will you live once that attention is gone?”

  4. #4
    Fanatic Member
    Join Date
    Feb 2002
    Location
    SE England
    Posts
    732
    I presume you want to check if you have access to a site etc, or if it is up and running?

    Try this.... ( I got it from www.ALLAPI.Net - check them out for everything API)

    Code:
    Const NETWORK_ALIVE_WAN = &H2
    Private Type QOCINFO
        dwSize As Long
        dwFlags As Long
        dwInSpeed As Long 'in bytes/second
        dwOutSpeed As Long 'in bytes/second
    End Type
    Private Declare Function IsDestinationReachable Lib "SENSAPI.DLL" Alias "IsDestinationReachableA" (ByVal lpszDestination As String, ByRef lpQOCInfo As QOCINFO) As Long
    Private Sub Form_Load()
        Dim Ret As QOCINFO
        Ret.dwSize = Len(Ret)
        If IsDestinationReachable("www.microsoft.com", Ret) = 0 Then
            MsgBox "The destination cannot be reached!"
        Else
            MsgBox "Destination found" + vbCrLf + _
               "The speed of data coming in from the destination is " + Format$(Ret.dwInSpeed / 1024, "#.0") + " Kb/s," + vbCrLf + _
               "and the speed of data sent to the destination is " + Format$(Ret.dwOutSpeed / 1024, "#.0") + " Kb/s."
        End If
    End Sub
    Leather Face is comin...


    MCSD

  5. #5
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Use ShellExecute
    Code:
    Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _
    String, ByVal lpFile As String, ByVal lpParameters As String, ByVal _
    lpDirectory As String, ByVal nShowCmd As Long) As Long
    Const SW_SHOWNORMAL = 1
    Private Sub Form_Load()
        ShellExecute Me.hwnd, vbNullString, "COMMAND.EXE", "PING www.vbforums.com", "C:\", SW_SHOWNORMAL
    End Sub
    Shellexec to CMD.EXE on NT systems.
    Also use a .BAT file -- change "PING" to MYPING.BAT"
    Code:
    REM MYPING.BAT
    PING %1

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