SHOW:
|
|
- or go back to the newest paste.
| 1 | @echo off | |
| 2 | color 1f | |
| 3 | Title NETWORK DIAGNOSTICS | |
| 4 | mode 80,13 | |
| 5 | cls | |
| 6 | echo. | |
| 7 | echo This script will test a few things and save the results in a file named | |
| 8 | echo "NetworkReport.txt" on your desktop. When the script is done, just send | |
| 9 | echo that file to your tech support person and they'll know what to do next! | |
| 10 | echo. | |
| 11 | pause | |
| 12 | ||
| 13 | echo. > %UserProfile%\Desktop\NetworkReport.txt | |
| 14 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 15 | echo INTERNET PING TEST >> %UserProfile%\Desktop\NetworkReport.txt | |
| 16 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 17 | ||
| 18 | ::::::::::::::::::::::::: | |
| 19 | :: INTERNET TEST :: | |
| 20 | ::::::::::::::::::::::::: | |
| 21 | ||
| 22 | ||
| 23 | echo. | |
| 24 | echo Testing your network connection and generating a report. | |
| 25 | echo Please wait... | |
| 26 | echo. | |
| 27 | set _PingWANworking=0 | |
| 28 | ||
| 29 | ::try to ping different WAN IP addresses. If all fail, user has no internet access. | |
| 30 | set _PingTarget=8.8.8.8 | |
| 31 | call :WANpingTest | |
| 32 | ||
| 33 | set _PingTarget=4.2.2.2 | |
| 34 | call :WANpingTest | |
| 35 | ||
| 36 | set _PingTarget=192.0.43.10 | |
| 37 | call :WANpingTest | |
| 38 | ||
| 39 | ::if internet is working, test DNS next. If not, skip testing DNS | |
| 40 | If %_PingWANworking% == 0 ( | |
| 41 | echo FAILED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 42 | echo The computer was unable to ping the following public IP addresses: >> %UserProfile%\Desktop\NetworkReport.txt | |
| 43 | echo 8.8.8.8, 4.2.2.2, 192.0.43.10 >> %UserProfile%\Desktop\NetworkReport.txt | |
| 44 | echo This computer DOES NOT have internet access. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 45 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 46 | goto SkipDNS | |
| 47 | ) ELSE ( | |
| 48 | echo PASSED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 49 | echo The computer IS able to ping public IP addresses. >> %UserProfile%\Desktop\NetworkReport.txt >> %UserProfile%\Desktop\NetworkReport.txt | |
| 50 | echo The computer DOES have internet access. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 51 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 52 | ) | |
| 53 | ||
| 54 | :::::::::::::::::::: | |
| 55 | :: DNS TEST :: | |
| 56 | :::::::::::::::::::: | |
| 57 | ||
| 58 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 59 | echo INTERNET DNS TEST >> %UserProfile%\Desktop\NetworkReport.txt | |
| 60 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 61 | echo. | |
| 62 | echo Testing DNS. | |
| 63 | echo Please wait... | |
| 64 | echo. | |
| 65 | set _DNSworking=0 | |
| 66 | ||
| 67 | ::try to ping different WAN domains. If all fail, DNS is not working. | |
| 68 | set _PingTarget=www.google.com | |
| 69 | call :WANpingTestDNS | |
| 70 | ||
| 71 | set _PingTarget=icann.org | |
| 72 | call :WANpingTestDNS | |
| 73 | ||
| 74 | set _PingTarget=amazon.com | |
| 75 | call :WANpingTestDNS | |
| 76 | ||
| 77 | If %_DNSworking% == 0 ( | |
| 78 | echo FAILED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 79 | echo The computer has internet access but DNS is not working. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 80 | echo It was able to ping at least one public IP address, but was not able to ping any of the >> %UserProfile%\Desktop\NetworkReport.txt | |
| 81 | echo following domain names by name: >> %UserProfile%\Desktop\NetworkReport.txt | |
| 82 | echo www.google.com, icann.org, amazon.com >> %UserProfile%\Desktop\NetworkReport.txt | |
| 83 | ) ELSE ( | |
| 84 | echo PASSED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 85 | echo DNS is working. The computer is able to ping external sites by name and by IP address. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 86 | ) | |
| 87 | ||
| 88 | :SkipDNS | |
| 89 | ||
| 90 | :::::::::::::::::::::::: | |
| 91 | :: GATEWAY TEST :: | |
| 92 | :::::::::::::::::::::::: | |
| 93 | :: Get the gateways into the variables | |
| 94 | for /f "tokens=2,3 delims={,}" %%a in ('"WMIC NICConfig where IPEnabled="True" get DefaultIPGateway /value | find "I" "') do (
| |
| 95 | set _ipv4GW=%%~a | |
| 96 | set _ipv6GW=%%~b | |
| 97 | ) | |
| 98 | set _ipv4Working=0 | |
| 99 | set _ipv6Working=0 | |
| 100 | set _gatewayworking=0 | |
| 101 | ||
| 102 | ||
| 103 | ::Try to ping the IPv4 gateway if enabled | |
| 104 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 105 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 106 | echo IPv4 GATEWAY TEST >> %UserProfile%\Desktop\NetworkReport.txt | |
| 107 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 108 | if [%_ipv4gw%]==[] goto 4disabled | |
| 109 | echo The IPv4 default gateway is detected as: %_ipv4GW% >> %UserProfile%\Desktop\NetworkReport.txt | |
| 110 | echo Note that if your computer has more than one default gateway, this may not be correct; see ipconfig /all, below >> %UserProfile%\Desktop\NetworkReport.txt | |
| 111 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 112 | ping -n 1 %_ipv4GW% | find "TTL=" | |
| 113 | if errorlevel 1 ( | |
| 114 | echo The default gateway %_ipv4GW% could not be reached. | |
| 115 | ) ELSE ( | |
| 116 | set _ipv4Working=1) | |
| 117 | ||
| 118 | If %_ipv4Working% == 1 ( | |
| 119 | echo PASSED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 120 | echo This computer IS able to ping the IPv4 default gateway. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 121 | ) ELSE ( | |
| 122 | echo FAILED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 123 | echo This computer is NOT able to ping the IPv4 default gateway. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 124 | ) | |
| 125 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 126 | :skipped4 | |
| 127 | ||
| 128 | ||
| 129 | ::Try to ping the IPv6 gateway if enabled | |
| 130 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 131 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 132 | echo IPv6 GATEWAY TEST >> %UserProfile%\Desktop\NetworkReport.txt | |
| 133 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 134 | if [%_ipv6gw%]==[] goto 6disabled | |
| 135 | echo The IPv6 default gateway is: %_ipv6GW% >> %UserProfile%\Desktop\NetworkReport.txt | |
| 136 | echo Note that if your computer has more than one default gateway, this may not be correct; see ipconfig /all, below. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 137 | echo %_ipv6GW% >nul | find "fe80::" | |
| 138 | If errorlevel 0 ( | |
| 139 | echo Note that this is a link-local IPv6 address, which means IPv6 may not be configured correctly. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 140 | ) | |
| 141 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 142 | ||
| 143 | ping -n 1 %_ipv6GW% | find /v "times" | find "time" | |
| 144 | if errorlevel 1 ( | |
| 145 | echo The default gateway %_ipv6GW% could not be reached. | |
| 146 | ) ELSE ( | |
| 147 | set _ipv6Working=1) | |
| 148 | ||
| 149 | If %_ipv6Working% == 1 ( | |
| 150 | echo PASSED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 151 | echo This computer IS able to ping the IPv6 default gateway. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 152 | ) ELSE ( | |
| 153 | echo FAILED >> %UserProfile%\Desktop\NetworkReport.txt | |
| 154 | echo This computer is NOT able to ping the IPv6 default gateway. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 155 | ) | |
| 156 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 157 | :skipped6 | |
| 158 | ||
| 159 | ||
| 160 | ::::::::::::::::::::::::: | |
| 161 | :: WIRELESS TEST :: | |
| 162 | ::::::::::::::::::::::::: | |
| 163 | ||
| 164 | ::check for wireless connection | |
| 165 | ::test if wlan service is running or not, then display wireless SSID info | |
| 166 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 167 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 168 | echo WIRELESS NETWORKING TEST >> %UserProfile%\Desktop\NetworkReport.txt | |
| 169 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 170 | sc query wlansvc | find "RUNNING" | |
| 171 | If errorlevel 1 ( | |
| 172 | echo The wireless service 'wlansvc' is not running. This MAY mean that the computer >> %UserProfile%\Desktop\NetworkReport.txt | |
| 173 | echo does not have a wireless card installed, or it may mean that wlansvc is having an issue. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 174 | ) ELSE ( | |
| 175 | netsh wlan show interfaces | find " SSID" | |
| 176 | IF errorlevel 1 ( | |
| 177 | echo The wireless service 'wlansvc' is running. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 178 | echo This means this computer likely has a working wireless adapter. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 179 | echo However the computer is NOT currently connected to a wireless network. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 180 | ) ELSE ( | |
| 181 | echo The computer IS currently connected to a wireless network. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 182 | netsh wlan show interfaces | find " SSID" >> %UserProfile%\Desktop\NetworkReport.txt | |
| 183 | ) | |
| 184 | ) | |
| 185 | ::APIPA DETECTOR:: | |
| 186 | ||
| 187 | ipconfig /all | find "169.254" | |
| 188 | if errorlevel 1 goto adapterinfo | |
| 189 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 190 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 191 | echo SELF ASSIGNED IP ADDRESS DETECTED (APIPA) >> %UserProfile%\Desktop\NetworkReport.txt | |
| 192 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 193 | echo Below please review IPCONFIG /ALL for more information. At least one self assigned IPv4 address was detected. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 194 | echo This means that the adapter was not able to receive a DHCP address, most likely due to a physical disconnection. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 195 | ||
| 196 | ||
| 197 | ||
| 198 | ||
| 199 | ::::::::::::::::::::::::: | |
| 200 | :: ADAPTER INFO :: | |
| 201 | ::::::::::::::::::::::::: | |
| 202 | :adapterinfo | |
| 203 | ::display enabled, disabled and disconnected adapters | |
| 204 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 205 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 206 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 207 | echo NETWORK ADAPTER STATUS CHECK >> %UserProfile%\Desktop\NetworkReport.txt | |
| 208 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 209 | echo The following network adapters are CONNECTED: (note that some of these may be virtual) >> %UserProfile%\Desktop\NetworkReport.txt | |
| 210 | echo ------------------------------------------------------------------------------------- >> %UserProfile%\Desktop\NetworkReport.txt | |
| 211 | wmic /append:%UserProfile%\Desktop\NetworkReport.txt path win32_networkadapter where (netconnectionstatus=2 AND PhysicalAdapter='TRUE') get name, macaddress, manufacturer, netconnectionID | |
| 212 | ||
| 213 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 214 | echo The following network adapters are DISABLED: (note that some of these may be virtual) >> %UserProfile%\Desktop\NetworkReport.txt | |
| 215 | echo ------------------------------------------------------------------------------------- >> %UserProfile%\Desktop\NetworkReport.txt | |
| 216 | wmic /append:%UserProfile%\Desktop\NetworkReport.txt path win32_networkadapter where (netconnectionstatus=0 AND PhysicalAdapter='TRUE') get name, macaddress, manufacturer, netconnectionID | |
| 217 | ||
| 218 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 219 | echo The following network adapters are DISCONNECTED: (note that some of these may be virtual) >> %UserProfile%\Desktop\NetworkReport.txt | |
| 220 | echo ----------------------------------------------------------------------------------------- >> %UserProfile%\Desktop\NetworkReport.txt | |
| 221 | wmic /append:%UserProfile%\Desktop\NetworkReport.txt path win32_networkadapter where (netconnectionstatus=7 AND PhysicalAdapter='TRUE') get name, macaddress, manufacturer, netconnectionID | |
| 222 | ||
| 223 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 224 | echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> %UserProfile%\Desktop\NetworkReport.txt | |
| 225 | echo Here are the results of IPCONFIG /ALL for further information: >> %UserProfile%\Desktop\NetworkReport.txt | |
| 226 | ipconfig /all >> %UserProfile%\Desktop\NetworkReport.txt | |
| 227 | ||
| 228 | cls | |
| 229 | echo. | |
| 230 | color 2f | |
| 231 | echo DIAGNOSTICS COMPLETE! | |
| 232 | echo. | |
| 233 | echo Look on your desktop for a text file named "NetworkReport.txt" | |
| 234 | echo Please send that file to the person that requested it. | |
| 235 | echo. | |
| 236 | echo If you are unable to email it from this computer, please instead | |
| 237 | echo save it onto a flash drive to bring to another computer, | |
| 238 | echo and then email the file to your helpdesk contact from there. | |
| 239 | echo. | |
| 240 | echo Please read the above, then press E to exit. | |
| 241 | Choice /c E | |
| 242 | If errorlevel 1 exit /b | |
| 243 | ::that's all, folks | |
| 244 | ||
| 245 | ||
| 246 | ::::::::::::::::: | |
| 247 | :: SUBROUTINES :: | |
| 248 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | |
| 249 | ||
| 250 | ||
| 251 | :WANpingTest | |
| 252 | Ping -n 1 %_PingTarget% | find /v "times" | find "time" | |
| 253 | If %errorlevel% == 0 set _PingWANworking=1 | |
| 254 | goto :EOF | |
| 255 | ||
| 256 | :WANpingTestDNS | |
| 257 | Ping -n 1 %_PingTarget% | find /v "times" | find "time" | |
| 258 | If %errorlevel% == 0 set _DNSworking=1 | |
| 259 | goto :EOF | |
| 260 | ||
| 261 | :4disabled | |
| 262 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 263 | echo This computer currently has no IPv4 default gateway. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 264 | echo The network adapter may be disabled or disconnected, IPv4 protocol may be disabled, >> %UserProfile%\Desktop\NetworkReport.txt | |
| 265 | echo or the computer may be failing to receive DHCP options. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 266 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 267 | goto skipped4 | |
| 268 | ||
| 269 | :6disabled | |
| 270 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 271 | echo This computer currently has no IPv6 default gateway. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 272 | echo The network adapter may be disabled or disconnected, IPv6 protocol may be disabled, >> %UserProfile%\Desktop\NetworkReport.txt | |
| 273 | echo or the computer may be failing to receive DHCP options. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 274 | echo. >> %UserProfile%\Desktop\NetworkReport.txt | |
| 275 | goto skipped6 |