How to save ipconfig and ping to TXT in CMD
Straightforward guide to output redirection in Windows.

Introduction

Output redirection lets you save command results to TXT files. It is useful for logs, diagnostics and documentation.

Essential operators

  • > overwrite file
  • >> append
  • 2> redirect errors
  • 2>&1 merge output + errors

Quick example: ping

ping 192.168.0.1 > ping.txt
ping -n 4 8.8.8.8 > ping_result.txt
ping -t 8.8.8.8 > ping_continuous.txt

Example: ipconfig

ipconfig /all > ipconfig.txt
ipconfig > ipconfig_basic.txt
ipconfig /displaydns > dns_cache.txt
echo %date% %time% >> ipconfig.txt && ipconfig /all >> ipconfig.txt

Useful network commands

netstat -an > active_connections.txt
route print > routing_table.txt
systeminfo > system_info.txt
tracert google.com > traceroute.txt

Timestamped logs

echo [%date% %time%] ping google.com >> net_log.txt
ping google.com >> net_log.txt

Other locations

ping google.com > C:\Logs\ping.txt
ping google.com > "%USERPROFILE%\Documents\ping.txt"
mkdir C:\Monitoring
ping google.com > C:\Monitoring\ping.txt

Automation with .bat

@echo off
ipconfig /all > ip_diagnostics.txt
ping -n 4 8.8.8.8 > connectivity.txt
nslookup google.com > dns_test.txt

Conclusion

With these operators you can create logs and diagnostics quickly.