Solved

Get IP Address (Batch File)

Posted on 2004-09-06
7
5,909 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now