Solved

VBScript for BGInfo to output what ISP I'm on

Posted on 2013-06-01
2
1,077 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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

772 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

13 Experts available now in Live!

Get 1:1 Help Now