Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Get IP Address (Batch File)

Posted on 2004-09-06
7
5,929 Views
Last Modified: 2012-06-27
I want to get the external Ip address of a computer. The computer has two IP addresses, one on the PPP adapter and one on the local network connection.

I want the one that can be seen from the internet.

It'll be passed into a batch file so i would consider a great answer to be if someone could parse the ipconfig details:


Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

      Connection-specific DNS Suffix  . :
      IP Address. . . . . . . . . . . . : 192.168.0.1
      Subnet Mask . . . . . . . . . . . : 255.255.255.0
      Default Gateway . . . . . . . . . :

PPP adapter BT Yahoo! Broadband:

      Connection-specific DNS Suffix  . :
      IP Address. . . . . . . . . . . . : 81.154.249.XX
      Subnet Mask . . . . . . . . . . . : 255.255.255.255
      Default Gateway . . . . . . . . . : 81.154.249.XX

(I've convered the last two octets for security reasons but they would be there!)

Can anyone help me parse this file or get me the IP address another way?

Thanks

 Phillip Taylor
0
Comment
Question by:Philluminati
7 Comments
 
LVL 57

Accepted Solution

by:
Pete Long earned 250 total points
ID: 11992032
Hi Philluminati,
see http:Q_20743821.html#9399250

Cheers!
0
 

Author Comment

by:Philluminati
ID: 11992079
Nope....doesn't work.

Doesn't even seem like a similar question if you ask me. Can someone parse the IP Address in the bottom half of the print out (above) and give me the code to do it?

Thanks

  Phill
0
 

Expert Comment

by:darkpred-learning
ID: 12086600
why dont u try this....

ipconfig/all > C:/path/ip.log

and then add a string with the value "mailto:" and your email...
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12239282
Okay! I have made in the past a batch file that does exactly that!

------Start of Batch Script!-----
@echo off
:: edit the two lines Below for your subject line and your email address
set to=someone@domain.com
set sub=Subject_line

for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set sub=%sub: =+%
start mailto:%to%?subject=%sub%^&body=The+IP+is;+%ip%
exit
-----End of Batch Script!-----

Good Luck!
- Shane
0
 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12239353
Sorry Mate my Code need a little Debuging.
Use this:
------Start of Batch Script!-----
@echo off
:: edit the two lines Below for your subject line and your email address
set to=someone@domain.com
set sub=Subject_line

for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set sub=%sub: =+%
set ip=%ip: =+%
start mailto:%to%?subject=%sub%^&body=The+IP+is;+%ip%
exit
-----End of Batch Script!-----

Good Luck! (again)
- Shane
0
 

Author Comment

by:Philluminati
ID: 12240448
This posting ended ages ago. I've solved the problem and awarded the points to the name specified.
0
 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12241516
Just adding extra help
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question