Tuesday, June 9, 2026

Computer Network Tool using batch scripting (Windows)

1. Copy and paste the script to Notepad or any text editor.

2. Save the script as networktoolkit.bat or networktoolkit.cmd.

3. Make sure to use a desktop or folder so that you can easily locate the file.

4. Right-click the file and run as administrator.
 
@echo off
title Windows Computer Network Toolkit
color 0A

:menu
cls
echo =====================================
echo     COMPUTER NETWORK TOOLKIT
echo =====================================
echo.
echo 1. Show Full IP Configuration
echo 2. Ping Google
echo 3. Flush DNS Cache
echo 4. Release IP Address
echo 5. Renew IP Address
echo 6. Reset Winsock
echo 7. Reset TCP/IP Stack
echo 8. Open Network Connections
echo 9. Open WiFi Settings
echo 10. Open Device Manager
echo 11. Open Network Troubleshooter
echo 12. Speed Test Ping
echo 13. Restart Explorer
echo 14. Exit
echo.

set /p choice=Enter Option:

if %choice%==1 ipconfig /all
if %choice%==2 ping google.com
if %choice%==3 ipconfig /flushdns
if %choice%==4 ipconfig /release
if %choice%==5 ipconfig /renew
if %choice%==6 netsh winsock reset
if %choice%==7 netsh int ip reset
if %choice%==8 start ncpa.cpl
if %choice%==9 start ms-settings:network-wifi
if %choice%==10 devmgmt.msc
if %choice%==11 msdt.exe /id NetworkDiagnosticsNetworkAdapter
if %choice%==12 ping 8.8.8.8 -t
if %choice%==13 taskkill /f /im explorer.exe & start explorer.exe
if %choice%==14 exit

pause
goto menu

 ------------------------------------------------------------------------------------------------------------

Purpose: 

The primary purpose of this batch script is to serve as a centralized, interactive Network Troubleshooting and Management Toolkit for Windows.

Instead of forcing a user to remember and manually type complex Command Prompt (cmd) instructions or dig through various Windows Settings menus, this script consolidates 14 essential network diagnostics and system recovery tools into a single, easy-to-use menu.

Core Functions & Capabilities

The script breaks down into four main categories of network and system management:

1. Network Diagnostics & Information

  • Show Full IP Configuration (ipconfig /all): Displays detailed information about all network adapters, IP addresses, MAC addresses, and DNS servers.

  • Ping Google (ping google.com) & Speed Test Ping (ping 8.8.8.8 -t): Tests internet connectivity and latency. The -t flag runs a continuous ping to help spot intermittent packet loss.

2. Network Reset & Recovery (The "Fix-It" Tools)

  • Flush DNS Cache (ipconfig /flushdns): Clears the local DNS cache, forcing Windows to grab fresh IP addresses for websites (great for fixing "site not found" errors).

  • Release/Renew IP (/release and /renew): Forces the router to drop your current local IP address and assign a new one via DHCP.

  • Winsock & TCP/IP Reset (netsh...): Deep-cleans the Windows network sockets and TCP/IP stack. This is the ultimate "nuclear option" when internet connectivity is completely broken despite being connected to Wi-Fi.

3. Windows GUI Shortcuts

  • Control Panel & Settings access: Quickly launches specific Windows management screens like Network Connections (ncpa.cpl), modern Wi-Fi Settings, and the Device Manager (to update or roll back network drivers).

  • Network Troubleshooter: Directly triggers the built-in Windows automated diagnostic tool for network adapters.

4. System Recovery

  • Restart Explorer (taskkill /f /im explorer.exe & start explorer.exe): Restarts the Windows Graphical User Interface (taskbar, desktop, file explorer). This is a handy trick to fix frozen screen elements or UI glitches without rebooting the whole PC.

Key Technical Limitations to Note

While highly useful, a few things to keep in mind regarding how this script is written:

  • Requires Administrative Privileges: Commands like netsh winsock reset and netsh int ip reset will fail silently if the script isn't explicitly run by right-clicking it and choosing "Run as administrator."

  • Input Vulnerability: The script uses basic if %choice%==X statements without error handling. If a user accidentally presses Enter without typing a number, or enters letters, the script will likely crash.

  • The Endless Loop (Option 12): Option 12 uses a continuous ping (-t). Because it never stops on its own, the user has to manually press Ctrl + C in the command window to break out of it and return to the menu.

 

No comments:

Post a Comment