Jump to content

Search the Community

Showing results for tags 'Test internet connection'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. This is a method to test connectivity to the Internet using the same approach as Mircosoft does, therefore no need to contact third party sites such as google or bing, which has often been the case. Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _MicrosoftInternetConnectivity ; Description ...: Test if the local machine is connected to the Internet using the same method as Microsoft for 'network awareness' minus the dns records verification. ; Syntax ........: _MicrosoftInternetConnectivity() ; Parameters ....: None ; Return values .: Success: True ; Failure: False ; Author ........: guinness ; Remarks .......: This will contact the website www.msftncsi.com. Works with Windows 2000+ ; Requires TCPStartup() to be initialised. ; The function has a restriction of contacting Microsoft every 15 seconds, so if you call the function within a tight loop then the last response will ; be returned and @extended set to non-zero. ; Link ..........: http://technet.microsoft.com/en-us/library/cc766017(v=ws.10).aspx#BKMK_How ; Example .......: Yes ; =============================================================================================================================== Func _MicrosoftInternetConnectivity() Local Static $hTimer = 0, _ ; Create a static variable to store the timer handle. $bLastResponse = Null ; Create a static variable to store the last response. If TimerDiff($hTimer) < 15000 And Not ($bLastResponse = Null) Then ; If still in the timer and $bLastResponse contains a value. Return SetExtended(1, $bLastResponse) ; Return the last response instead and set @extended to 1. EndIf Local $bEnableActiveProbing = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\', 'EnableActiveProbing') > 0 If @error Then $bEnableActiveProbing = True EndIf If Not $bEnableActiveProbing Then Return False EndIf Local $sContent = 'Microsoft NCSI', _ $sDNSHost = 'dns.msftncsi.com', _ $sDNSIPAddress = '131.107.255.255', _ $sURL = 'http://' & RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\', 'ActiveWebProbeHost') & '/' & RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\', 'ActiveWebProbePath') If $sURL == 'http:///' Then $sURL = 'http://www.msftncsi.com/ncsi.txt' Else $sContent = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\', 'ActiveWebProbeContent') $sDNSIPAddress = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\', 'ActiveDnsProbeContent') $sDNSHost = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet\', 'ActiveDnsProbeHost') EndIf $bLastResponse = BinaryToString(InetRead($sURL, $INET_FORCERELOAD)) == $sContent And TCPNameToIP($sDNSHost) == $sDNSIPAddress Return $bLastResponse EndFunc ;==>_MicrosoftInternetConnectivity Example use of Function: #include <InetConstants.au3> #include <MsgBoxConstants.au3> Example() Func Example() TCPStartup() Local $bConnected = _MicrosoftInternetConnectivity() MsgBox($MB_SYSTEMMODAL, '', 'Is the Internet working?: ' & ($bConnected ? 'Yes, the Internet is working.' : 'No, the Internet isn''t working.')) TCPShutdown() EndFunc ;==>Example
×
×
  • Create New...