Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get IP Address (Batch File)

Posted on 2004-09-06
7
Medium Priority
?
5,972 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 750 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

773 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