[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VBScript for BGInfo to output what ISP I'm on

Posted on 2013-06-01
2
Medium Priority
?
1,344 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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 make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Six Sigma Control Plans
Starting up a Project

649 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