Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
how to ping from Access
Dan Pickle 
     
3 years ago
I have a database that has an IP address field in itupon double click of the IP address I want to be able to ping that address.  I thought it would be done by the shell command but that is not working (at least the couple of different ways I have tried.  Is this possible to do and if so how?

Thanks
Alex Hedley  @Reply  
           
3 years ago
What did you try? And what error messages did you get, if any?
Did you try manually in cmd and did it work?
Dan Pickle OP  @Reply  
     
3 years ago
I can open up cmd on the PC and ping 192.168.1.1 with no issue.  I tried this Shell "ping 8.8.8.8", vbNormalFocus and it returns invalid procedure call or argument then I tried to just open a command prompt with Shell "cmd.exe", vbNormalFocus and I get the same error.  then I tried the full path Shell "c:\windows\system32\cmd.exe", vbNormalFocus and still the same error
Alex Hedley  @Reply  
           
3 years ago
Shell(Program,WindowStyle)

Can you try Shell("ping 8.8.8.8", vbNormalFocus) instead?
Alex Hedley  @Reply  
           
3 years ago
C:\> where ping
| C:\Windows\System32\PING.EXE

ping
Dan Pickle OP  @Reply  
     
3 years ago
I tried both Shell("ping 8.8.8.8", vbNormalFocus) and Shell("C:\Windows\System32\PING.EXE 8.8.8.8", vbNormalFocus) and both return a compile error syntax error.  I even tried Shell("C:\Windows\System32\cmd.exe", vbNormalFocus) just to see if I could get a command prompt to show up and I get the same error
Alex Hedley  @Reply  
           
3 years ago
Are you running this from a button click?

What's the full code you're using?
Kevin Yip  @Reply  
     
3 years ago
Hi Dan, you may be using incorrect syntax.

If you don't request a return value, don't use parentheses:

    Shell "ping yahoo.com", vbNormalFocus

Use parentheses if you request a return value (to confirm a successful execution):

    Dim r As Variant
    r = Shell("ping yahoo.com", vbNormalFocus)
Dan Pickle OP  @Reply  
     
3 years ago
ok I tried Dim r As Variant
    r = Shell("ping yahoo.com", vbNormalFocus) and I get invalid procedure or argument.  I also tried Shell "ping yahoo.com", vbNormalFocus and I get the same result

Alex, currently I am using a button but once I get it working I plan to use it as a double click event where you double click on the machine name and it will ping it or you can double click on the IP address and it will ping it.  the full code I am currently using is this


Private Sub Command15_Click()
Shell "ping yahoo.com", vbNormalFocus
End Sub
Kevin Yip  @Reply  
     
3 years ago
Let's try using ping without using Shell:

    Dim ws As Variant
    Set ws = CreateObject("WScript.Shell")
    ws.Run "ping yahoo.com"

This above code is VBScript, which is VBA little brother.  It is often used in ASP, but can be used in VBA environment too.  It creates a "Windows Scripting" object, which can run commands just like Shell.

Dan Pickle OP  @Reply  
     
3 years ago
I tried
Dim ws As Variant
    Set ws = CreateObject("WScript.Shell")
    ws.Run "ping yahoo.com"
and now I get a permission denied error
Kevin Yip  @Reply  
     
3 years ago
You may be lacking permission and/or administrative rights to certain files and folders.

Now try:

    Shell "msaccess", vbNormalFocus

It will open another instance of Access.  Since you are already running Access, you most likely already have the fullest rights to the files and folders set up for Access (and Office).

Try running Word too:

    Shell "msword", vbNormalFocus

If this is a business environment and you have an IT person overseeing all the computer users, you may talk with him or her to see if your rights are indeed restricted.
Dan Pickle OP  @Reply  
     
3 years ago
I do have full administrative rights here at work but I can try at home tonight
Dan Pickle OP  @Reply  
     
3 years ago
well son of a biscuit eater that was it!  Corporate has been blocking me!   I tried the ping command from home and......It worked!  then I tried a longer command that I found elsewhere
Private Sub IpAddress_DblClick(Cancel As Integer)
    If IsNull(IpAddress) Then Exit Sub
    Dim strCommand
    Dim iRet

    strCommand = "%SystemRoot%\system32\ping.exe -n 1 -l 1 -w 500 " & IpAddress
    iRet = fShellRun(strCommand)

    If iRet <> 0 Then
        MsgBox "Not Connected"
    Else
        MsgBox "Connected!"
    End If
End Sub

'''''''''''''''''''''''''''

Function fShellRun(sCommandStringToExecute)

        ' This function will accept a string as a DOS command to execute.
        ' It will then execute the command in a shell, and returns the command
        ' return code to the caller.

        ' "ComputerName" is a user-selected global variable

        Dim oShellObject

        Set oShellObject = CreateObject("Wscript.Shell")

        On Error Resume Next
        fShellRun = oShellObject.Run(sCommandStringToExecute, 0, True)

End Function

which actually gave me the end result I was looking for and that worked as well but at work both refused to run!  Time to reach out to corporate

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/24/2026 10:45:05 AM. PLT: 1s