Batch file examples to run ipconfig

Save the following text into a file with a .bat extension (for example, ipconfig_run.bat). Double‑click the file to run it.

Simple one-line version:

@echo off
ipconfig
pause

More detailed version that saves output to a timestamped text file and also shows it:

@echo off
rem Get timestamp components
for /f "tokens=1-4 delims=/:. " %%a in ("%date% %time%") do (
  set _d=%%a
  set _m=%%b
  set _y=%%c
  set _t=%%d
)
rem Create a filename like ipconfig_YYYYMMDD_HHMMSS.txt
set filename=ipconfig_%_y%%_m%%_d%_%_t%.txt

ipconfig > "%~dp0%filename%"
type "%~dp0%filename%"

echo.
echo Output saved to: %~dp0%filename%
pause

Notes:

  • The first script runs ipconfig and leaves the console open with pause so you can read results.
  • The second script redirects output to a file in the same folder as the .bat (%~dp0) and displays it.
  • Run the .bat with Administrator privileges if you need details from ipconfig /all /renew /release.

Have your own question?

Ask the AI now

Free · no account needed · answer in seconds