Jump to content

Function To Detect Lan Connection

Recommended Posts

Net use would be executing an external command.

The idea i just had was using URLDownloadToFile and grabbing a small item from an intranet page.

$Connected = URLDownloadToFile("http://intranet.com/spacer.gif", @TempDir & "\tmp.gif")
Edited by bcording
Link to post
Share on other sites

Probably the easist way would be to check the Macros "@IPAddress1" through "@IPAddress4" to see if the address is something other than "" (invalid) or "" (localhost). "@IPAddress1" should be the only one that you'd need to check in most cases.

Please keep in mind that it's not the best way to test for connectivity, but it should be somewhat reliable. :whistle:

Link to post
Share on other sites

Ping relies on executing an external program, something i want to avoid. The idea of looking at the IP address helps, but simply means you have an IP. The method i found using URLDownloadToFile is working fine. Thanks all.

Link to post
Share on other sites

If you are trying to check LAN connection, use any file checking function to any on the server or anouther workstation share.

If you wish to Check WAN or internet, URLDownloadToFile() is a nice AutoIt only solution.

I prefer to use ping though, fast and reliable.

JdeB posted a small one I think:

; Run ping with count=1 and timeout = 1 second
$rc = RunWait(@comspec &  ' /c ping -n 1 -w 1000','',@SW_HIDE)
If $rc = 0 Then
; host exists
; host doesn't exists

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...