Solved

VBScript for BGInfo to output what ISP I'm on

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# application error "Parameter Is Not Valid". 3 130
Android development question 2 75
ASP/VB email question 4 61
Programming Language for Wordpress 7 62
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

713 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