Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    I want to make a form with buttons with shell commands.
    A button F.e. ping request.
    When the ping request is finished, I have to get a messagebox with f.e. "Ping successfull"

    Is This possible?

    Many thanks
    Kind regards,
    Nancy

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Hi Nancy,
    Unfortunately, I don't think it is possible to do exactly what you describe in your post. As I understand it, the Ping command has to be run in a command window, and because of that, it won't return an indication of success or failure to Access. But maybe your Ping command was just an example. What kinds of functions are you wanting to perform from the Access form?
    Wendell

  3. #3
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Here is a link to an MS page that discusses PING from VB
    Although VB I am sure it also applies to VBA

    The implications are that it would need to be done with an API call if you want to try and get a return status.

    PING LINK
    Andrew

  4. #4
    Star Lounger
    Join Date
    Mar 2002
    Location
    Haaltert, Belgium
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WendellB View Post
    Hi Nancy,
    Unfortunately, I don't think it is possible to do exactly what you describe in your post. As I understand it, the Ping command has to be run in a command window, and because of that, it won't return an indication of success or failure to Access. But maybe your Ping command was just an example. What kinds of functions are you wanting to perform from the Access form?
    Hello,
    This is what I got so fare:
    Code:
    Shell ("pingtest.bat " & "namecomputer")
    In the pingtest.bat is written:
    Code:
    ping %1 >> "D:\path\%1.txt"
    In a text file I'll get the resulst of the ping request.
    Then I want to display only the result of the text file in a form or message box and not the whole text file.

  5. #5
    New Lounger
    Join Date
    Dec 2009
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    shell "ping -n 1 " & namecomputer & " | find /i ""reply"" >D:\path\" & namecomputer & ".txt"
    will ping the namecomputer address once, and write into the named file either of the following:
    Reply from namecomputer bytes=32 time=217ms TTL=47 if Ping was successful
    or
    Nothing if Ping was unsuccessful.

    Now you have to read the contents of the named file into a variable, and display the value in your Msgbox.

    You can also add a timeout to your Ping command (measured in milliseconds), as in:
    Code:
    shell "ping -n 1 -w 200 " & namecomputer & " | find /i ""reply"" >D:\path\" & namecomputer & ".txt"
    Be aware that Shell returns control to Access before the command being executed has completed. There are several methods to force your application to wait until Ping has finished - in this case, the simplest might be to insert a Sleep command (requires an API call), or loop until the named file has been created (make sure it doesn't already exist).

Posting Permissions

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