Sign in to follow this  
Followers 0
bcording

Function To Detect Lan Connection

7 posts in this topic

How would you do it with out executing an external program? Is there a registry key? Some file?

Share this post


Link to post
Share on other sites



Have you tried using NET USE?


Hope this was helpful.............good luck, Bob

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


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 "0.0.0.0" (invalid) or "127.0.0.1" (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:

Share this post


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.

Share this post


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 192.168.100.100 -n 1 -w 1000','',@SW_HIDE)
If $rc = 0 Then
; host exists
Else
; host doesn't exists
EndIf

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


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
Sign in to follow this  
Followers 0