Question : Find Local IP in batch file

This is the only section of the script that doesn't work.  It does pull the IP, but it outputs the IP with a leading space which kills the rest of my script.

Ex.
 192.168.1.100
When it needs to be
192.168.1.100

What am I doing wrong here?  The rest of my script works well.
Code Snippet:
1:
2:
3:
4:
::discover the local IP
:LOCALIP
for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set LOCALIP=%%a
echo %localip%
Open in New Window Select All

Answer : Find Local IP in batch file

You can get rid of the space, either by using a substring to chop off the first character, e.g.
set localip=%localip:~1%

or by using substitution to remove all spaces from the variable, e.g.
set localip=%localip: =%
Random Solutions  
 
programming4us programming4us