Last active
May 20, 2016 22:30
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 ) | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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