Skip to content

Instantly share code, notes, and snippets.

@tzkmx
Last active May 20, 2016 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzkmx/3161d5d211a9467833c863c83cdda252 to your computer and use it in GitHub Desktop.
Save tzkmx/3161d5d211a9467833c863c83cdda252 to your computer and use it in GitHub Desktop.
Loops to get first IPv4 address in CMD && then reset ini file to result
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET _c=0
FOR /F "delims=: tokens=1,2" %%A IN ('ipconfig') DO (
FOR /F "tokens=2" %%C IN ("%%A") DO (
IF !_c! EQU 0 IF /I %%C==IPv4. ( echo %%B & SET /A _c+=1 )
)
)
@ECHO OFF
SET iniFile=C:\ProgramData\config.ini
FOR /F %%D IN ('\\server\scripts_share\getFirstIPv4.bat') DO SET _ip=%%D
IF DEFINED _ip (
ECHO [Pc-Config] > %iniFile%
ECHO Ip=%_ip% >> %iniFile%
FOR /F "delims=. tokens=4" %%I IN ("%_ip%") DO ECHO Pc=%%I >> %iniFile%
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment