Windows Batch: Automatic check of network connectivity

Source: Internet
Author: User
Tags delete cache

Detecting network Connectivity I'm using the Cong approach, which is " External Network -- Gateway -- Intranet -- This machine " , the implementation of the script is also based on this order Ping to detect, in order to improve the detection speed, here I only Ping the 2 times, you can make changes according to your own needs.

How to use the great gods will ...  copy code, save as . Bat after the file is executed.

1 @echo off2 Color 2F3 Title Network connectivity detection4 Echo.5 ifExist%temp%\*.PingDel%temp%\*.Ping:: Delete Cache6 Echo.7 Ping-N2223.5.5.5>>%temp%\1.Ping&Ping-N2223.6.6.6>>%temp%\1.Ping::p ing ali public DNS address8Findstr"TTL"%temp%\1.Ping>nul9 if%errorlevel%==0(Echo√ External network normal)Else(Echox Outside Network):: Return value output according to commandTen Echo. One Ping-N2192.168.1.1>>%temp%\2.Ping AFindstr"TTL"%temp%\2.Ping>nul - if%errorlevel%==0(Echo√ Gateway Normal)Else(Echox Gateway not through) - Echo. the Ping-N2192.168.1.2>>%temp%\3.Ping -Findstr"TTL"%temp%\3.Ping>nul - if%errorlevel%==0(Echo√ Normal intranet)Else(Echox Intranet not through) - Echo. + Ping-N2127.0.0.1>>%temp%\4.Ping -Findstr"TTL"%temp%\4.Ping>nul + if%errorlevel%==0(Echo√TCP/IP protocol OK)Else(Echoxtcp/IP Protocol Exception) A Echo. at Echo. -Pause

The effect is as follows:

Windows Batch: Automatically check network connectivity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.