Solved

VBScript for BGInfo to output what ISP I'm on

Posted on 2013-06-01
2
1,155 Views
Last Modified: 2013-06-01
Need assistance creating a script that gets the Public IP Address and sends this information to
http://whatismyipaddress.com/ip/<PublicAddress>, and then returns the ISP for that IP Address to display in BGInfo. I am just learning how to script and not that experienced yet.
0
Comment
Question by:crp0499
2 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 39213593
whatismyipaddress returns your public address.  So not sure why you wouldn't use it to both retrieve your public ip address and your isp.  Here's a vbscript example:

option explicit

class whatsmyip

   public response

   sub class_initialize
       dim xmlhttp
       set xmlhttp = wscript.createobject("Microsoft.XMLHttp")  
       xmlhttp.open "GET","http://whatismyipaddress.com", False
       xmlhttp.send
       me.response = xmlhttp.responsetext
   end sub

   private function find_it(pattern)
       dim re, matches
       set re = new RegExp
       re.pattern = pattern
       re.multiline = True
       set matches = re.execute(me.response)
       if matches.count > 0 then
           find_it = matches(0).submatches(0)
       else 
           find_it = ""
       end if 
   end function

   public function get_ip
       get_ip = find_it("(\d+\.\d+\.\d+\.\d+)")
   end function

   public function get_isp
       get_isp = find_it("<th>ISP:</th><td>(.*?)</td>")
   end function

end class

dim myip
set myip = new whatsmyip
wscript.echo "IP: " & myip.get_ip
wscript.echo "ISP: " & myip.get_isp

Open in new window

0
 

Author Closing Comment

by:crp0499
ID: 39213651
Thank you,  you are a genius. That's exactly what I was looking for. I had to make a few changes to work in bginfo, but that was on the money.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

815 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

12 Experts available now in Live!

Get 1:1 Help Now