Computing.Net > Forums > Disk Operating System > Extract IP address for use in batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extract IP address for use in batch file

Reply to Message Icon

Name: Neil Strawbridge
Date: August 1, 2002 at 09:54:28 Pacific
Comment:

Hello:

I'm creating a batch file which at one point should put the machine's TCP/IP address into a variable. If this were a system variable, it would be easy.

I'm using Windows 2000, so I already have variables such as USERDOMAIN, USERNAME, COMPUTERNAME. However, it would be most helpful if I could also get the TCP/IP address and the subnet mask information in there as well.

I'm aware this information can come from IPCONFIG. But how do I get just the numbers?

Any help would be greatly appreciated!!


All the Best,
Neil



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: August 1, 2002 at 14:20:00 Pacific
Reply:

This works for WinXP, should also work on Win2K:

@echo off
IPCONFIG |FIND "IP" > %TEMP%.\TEMP.DAT
FOR /F "tokens=2 delims=:" %%a in (%TEMP%.\TEMP.DAT) do set IP=%%a
del %TEMP%.\TEMP.DAT
set IP=%IP:~1%
echo IP=%IP%

Watch out for line wrapping!

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0
Reply to Message Icon

Related Posts

See More


Looking for a DOS driver ... Formating a HDD with Many...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Extract IP address for use in batch file

Dos batch file www.computing.net/answers/dos/dos-batch-file/8191.html

Using 'for' cmd in batch file. www.computing.net/answers/dos/using-for-cmd-in-batch-file/13417.html

Math in Batch File www.computing.net/answers/dos/math-in-batch-file/13315.html