Introduction
When diagnosing connectivity problems, there are several common checks that can help to quickly identify where a fault exists. This script automates a number of basic troubleshooting steps and provides useful diagnostic information.
What the Script Checks
- Check network connection status (Show IP, DNS, Gateway)
- Test Internet & DNS Connectivity (Ping Test)
- Test Connection to Router (Gateway Ping Test)
- Flush DNS Cache (Fix page loading / address resolution issues)
- Release & Renew IP Address (Requestion new connection to Router)
- Complete Network Stack Reset (Fix deep connection errors – Requires reboot. Last resort)
- Run Windows Built-in Network Troubleshooter
When Should You Use This Tool?
- No internet connectivity
- Slow browsing
- DNS errors
- Unable to access websites
- Troubleshooting home broadband issues
Disclaimer:
This script is provided “as is” for convenience and general use. It is not officially supported, maintained, or warranted in any way.
By using this script, you acknowledge that you do so at your own risk. The author accepts no responsibility or liability for any issues, errors, data loss, system damage, downtime, security impacts, or other consequences arising from the use or misuse of this script.
Compatibility
- Windows 11
Download
- Download and unzip the compressed ZIP file.
- Save NetworkToolkit.bat to a location on your PC
- Double click NetworkToolkit.bat to run
Source Code
@echo off
setlocal enabledelayedexpansion:: Check for Administrator Privileges
net session >nul 2>&1
if %errorLevel% neq 0 (
echo ============================================================
echo ADMINISTRATOR PRIVILEGES REQUIRED
echo ============================================================
echo This toolkit needs Administrator permissions to perform
echo advanced network tests and repairs.
echo.
echo Requesting admin privileges…
echo ============================================================
powershell -Command “Start-Process -FilePath ‘%~f0’ -Verb RunAs”
exit /b
):: Set title and color (0B = Aqua text on black background)
title Network Troubleshooting Toolkit
color 0B:MainMenu
cls
echo ================================================================================
echo WINDOWS NETWORK TROUBLESHOOTING TOOLKIT
echo ================================================================================
echo This tool helps you diagnose and repair common network and Internet issues.
echo Practical Technology by Russell Bosworth
echo.
echo Disclaimer:
echo This script is provided “as is” for convenience and general use. It is not
echo officially supported, maintained, or warranted in any way.
echo.
echo By using this script, you acknowledge that you do so at your own risk. The
echo author accepts no responsibility or liability for any issues, errors, data loss,
echo system damage, downtime, security impacts, or other consequences arising from
echo the use or misuse of this script.
echo ================================================================================
echo.
echo DIAGNOSTICS:
echo [1] Check Network Connection Status (Show IP, DNS, Gateway)
echo [2] Test Internet ^& DNS Connectivity (Ping Test)
echo [3] Test Connection to Router (Gateway Ping Test)
echo.
echo REPAIRS:
echo [4] Flush DNS Cache (Fix page loading / address resolution issues)
echo [5] Release ^& Renew IP Address (Request new connection to router)
echo [6] Complete Network Stack Reset (Fix deep connection errors – Requires Reboot)
echo [7] Run Windows Built-in Network Troubleshooter
echo.
echo EXIT:
echo [8] Exit Toolkit
echo.
echo ================================================================================
set “choice=”
set /p choice=”Select an option (1-8): “if “%choice%”==”1” goto :ConnectionStatus
if “%choice%”==”2” goto :PingTest
if “%choice%”==”3” goto :GatewayPing
if “%choice%”==”4” goto :FlushDNS
if “%choice%”==”5” goto :ReleaseRenew
if “%choice%”==”6” goto :ResetStack
if “%choice%”==”7” goto :Troubleshooter
if “%choice%”==”8” goto :ExitScriptecho.
echo Invalid selection. Please choose a number from 1 to 8.
timeout /t 2 >nul
goto :MainMenu:ConnectionStatus
cls
echo ================================================================================
echo CURRENT NETWORK CONNECTION STATUS
echo ================================================================================
echo.
echo Retrieving active network interface information…
echo.
powershell -Command “Get-NetIPConfiguration | Where-Object {$_.IPv4Address -ne $null} | ForEach-Object { Write-Host ‘Adapter Name : ‘ -NoNewline -ForegroundColor Green; Write-Host $_.InterfaceAlias -ForegroundColor White; Write-Host ‘ IPv4 Address : ‘ -NoNewline; Write-Host ($_.IPv4Address.IPAddress -join ‘, ‘); Write-Host ‘ Default Gateway : ‘ -NoNewline; Write-Host ($_.IPv4DefaultGateway.NextHop -join ‘, ‘); Write-Host ‘ DNS Servers : ‘ -NoNewline; Write-Host ($_.DNSServer.ServerAddresses -join ‘, ‘); Write-Host ” }”
echo ================================================================================
echo Press any key to return to the Main Menu…
pause >nul
goto :MainMenu:PingTest
cls
echo ================================================================================
echo TESTING INTERNET ^& DNS CONNECTIVITY
echo ================================================================================
echo.
echo 1. Testing physical/IP connection to the Internet (Ping Google DNS 8.8.8.8)…
ping -n 3 8.8.8.8 >nul
if %errorLevel% == 0 (
powershell -Command “Write-Host ‘ SUCCESS: Raw internet connection is active!’ -ForegroundColor Green”
set internet_ok=1
) else (
powershell -Command “Write-Host ‘ FAILURE: Could not reach Google DNS. Your internet link is down.’ -ForegroundColor Red”
set internet_ok=0
)
echo.
echo 2. Testing web address lookup (Ping google.com)…
ping -n 3 google.com >nul
if %errorLevel% == 0 (
powershell -Command “Write-Host ‘ SUCCESS: DNS Resolution is working properly!’ -ForegroundColor Green”
set dns_ok=1
) else (
powershell -Command “Write-Host ‘ FAILURE: Could not resolve address. DNS lookup is failing.’ -ForegroundColor Red”
set dns_ok=0
)
echo.
echo ================================================================================
echo DIAGNOSIS:
if %internet_ok% == 1 (
if %dns_ok% == 1 (
powershell -Command “Write-Host ‘ Your Internet connection is fully operational.’ -ForegroundColor Green”
) else (
powershell -Command “Write-Host ‘ You have physical connection, but web pages won”t load.’ -ForegroundColor Yellow”
powershell -Command “Write-Host ‘ Suggestion: Run Option [4] Flush DNS or Option [5] Release/Renew IP.’ -ForegroundColor Yellow”
)
) else (
powershell -Command “Write-Host ‘ You are completely disconnected from the Internet.’ -ForegroundColor Red”
powershell -Command “Write-Host ‘ Suggestion: Check physical wires/Wi-Fi connection, then run Option [3] to check router connection.’ -ForegroundColor Red”
)
echo ================================================================================
echo Press any key to return to the Main Menu…
pause >nul
goto :MainMenu:GatewayPing
cls
echo ================================================================================
echo TESTING CONNECTION TO YOUR ROUTER
echo ================================================================================
echo.
powershell -Command “$gw = (Get-NetIPConfiguration | Where-Object {$_.IPv4DefaultGateway -ne $null} | Select-Object -First 1).IPv4DefaultGateway.NextHop; if ($gw) { Write-Host \”Found Router/Gateway Address: $gw\”; Write-Host ‘Pinging gateway…’; ping $gw } else { Write-Host ‘ERROR: No active network connection or Default Gateway found!’ -ForegroundColor Red; Write-Host ‘Please ensure your network cable is plugged in or Wi-Fi is connected.’ -ForegroundColor Yellow }”
echo.
echo ================================================================================
echo Press any key to return to the Main Menu…
pause >nul
goto :MainMenu:FlushDNS
cls
echo ================================================================================
echo FLUSHING DNS RESOLVER CACHE
echo ================================================================================
echo.
echo Clearing local DNS cache…
ipconfig /flushdns
echo.
echo Clearing ARP (address resolution) cache…
arp -d * >nul 2>&1
echo.
powershell -Command “Write-Host ‘SUCCESS: DNS and address caches have been flushed!’ -ForegroundColor Green”
echo This fixes problems where websites won’t load because of outdated records.
echo.
echo ================================================================================
echo Press any key to return to the Main Menu…
pause >nul
goto :MainMenu:ReleaseRenew
cls
echo ================================================================================
echo RELEASING ^& RENEWING IP ADDRESS
echo ================================================================================
echo.
echo Releasing current IP address configuration…
ipconfig /release >nul 2>&1
echo.
echo Requesting a new IP address from your router…
ipconfig /renew
echo.
powershell -Command “Write-Host ‘SUCCESS: IP address has been renewed!’ -ForegroundColor Green”
echo This re-establishes your connection to the local router.
echo.
echo ================================================================================
echo Press any key to return to the Main Menu…
pause >nul
goto :MainMenu:ResetStack
cls
echo ================================================================================
echo COMPLETE NETWORK STACK RESET
echo ================================================================================
echo.
powershell -Command “Write-Host ‘WARNING: This will reset all network protocols to default settings.’ -ForegroundColor Yellow”
powershell -Command “Write-Host ‘This is a powerful fix for deep errors, but requires restarting your computer.’ -ForegroundColor Yellow”
echo.
set /p confirm=”Are you sure you want to proceed? (Y/N): “
if /i “%confirm%” neq “Y” (
echo Reset cancelled. Returning to main menu.
timeout /t 2 >nul
goto :MainMenu
)
echo.
echo Resetting Winsock catalogs (network API)…
netsh winsock reset
echo.
echo Resetting TCP/IP protocol stack…
netsh int ip reset
echo.
echo Resetting TCP settings…
netsh int tcp reset >nul 2>&1
echo.
powershell -Command “Write-Host ‘SUCCESS: Network stack reset completed successfully!’ -ForegroundColor Green”
echo.
set /p reboot=”Would you like to restart your computer now to apply changes? (Y/N): “
if /i “%reboot%”==”Y” (
echo.
echo Restarting computer in 10 seconds. Save your work!
shutdown /r /t 10 /c “Network Toolkit – Network Stack Reset Completed”
exit /b
)
echo.
echo Remember to restart your computer manually for changes to take full effect.
echo.
echo ================================================================================
echo Press any key to return to the Main Menu…
pause >nul
goto :MainMenu:Troubleshooter
cls
echo ================================================================================
echo LAUNCHING WINDOWS NETWORK DIAGNOSTICS
echo ================================================================================
echo.
echo Starting the built-in Windows diagnostics wizard…
msdt.exe -id NetworkDiagnosticsWeb
echo.
echo The wizard has launched in a separate window.
echo Follow the steps on screen to identify additional issues.
echo.
echo ================================================================================
echo Press any key to return to the Main Menu…
pause >nul
goto :MainMenu:ExitScript
cls
echo Thank you for using the Network Troubleshooting Toolkit!
echo Exiting…
timeout /t 2 >nul
exit /b
