Introduction
Batch provides built-in commands for checking connections, diagnosing network issues, mapping drives, pinging servers, and automating network tasks. These commands are powerful for sysadmins and automation scripts.
1. PING – Test Connectivity
ping google.com
2. IPCONFIG – View Network Info
ipconfig /all
3. RENEW / RELEASE IP
ipconfig /release
ipconfig /renew
4. FLUSHDNS – Clear DNS Cache
ipconfig /flushdns
5. TRACERT – Trace Route
tracert google.com
6. NETSTAT – View Active Connections
netstat -an
- -a — all connections
- -n — numeric mode
7. Network Drive Mapping
net use Z: \\Server\SharedFolder /user:Admin Pass123
Remove drive:
net use Z: /delete /y
8. Check Open Ports
netstat -ano | find ":80"
9. Check If a Host Is Reachable
ping 192.168.1.1 >nul
if not errorlevel 1 (
echo Host reachable
) else (
echo Host unreachable
)
10. FTP Automation
Automating FTP uploads using a script.
echo open ftp.server.com> ftpcmd.txt
echo user username password>> ftpcmd.txt
echo put file.zip>> ftpcmd.txt
echo quit>> ftpcmd.txt
ftp -s:ftpcmd.txt
11. CURL on Windows
Windows 10+ includes curl by default.
curl https://api.ipify.org
12. NSLOOKUP
nslookup google.com
13. Test Internet Speed (Simple)
curl -o nul https://speed.hetzner.de/100MB.bin
14. Automatically Reconnect Network Drives
@echo off
net use Z: /delete /y
net use Z: \\Server\Files /persistent:yes
15. Monitor Network Status in Loop
:loop
ping google.com -n 1 >nul
if errorlevel 1 (
echo No internet!
) else (
echo Connected.
)
timeout /t 5 >nul
goto loop
Summary
pingtests connectivityipconfigmanages IP/DNS settingsnetstatshows open portsnet usemaps network drivestracerttraces connection pathsftpandcurlautomate uploads and downloads- Network loops can monitor connectivity