Batch Files - Using ping to test network connectivity

前端 未结 8 1092
名媛妹妹
名媛妹妹 2021-01-04 17:17

Using a batch file would it be possible to do something like:

ping google.com

if return success do ECHO You are connected to the internet

else return

8条回答
  •  Happy的楠姐
    2021-01-04 17:55

    @echo off
    echo Checking connection
    ping -n 1 www.google.com >nul
    if errorlevel 1 (
      cls
      echo Failed
      pause>nul
      exit
    )
    
    cls
    echo Success!
    pause>nul
    exit
    

提交回复
热议问题