Solved

VBScript for BGInfo to output what ISP I'm on

Posted on 2013-06-01
2
1,274 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
[X]
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
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
Introduction to Processes

726 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