BGInfo – Script for Local IP, Public IP and ISP Name

I recently created 3 scripts for BGInfo … If you need it, use it ;)

Local IP.vbs

I found this script at ardamis.com and adapted to my needs. I removed VMware local IP, because I don’t need it

strMsg = ""
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress,description from Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'")
 
For Each IPConfig in IPConfigSet
	If Not IsNull(IPConfig.IPAddress) Then
	For i = LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
		If Not Instr(IPConfig.IPAddress(i), ":") > 0 Then
			If InStr(1, IPConfig.description(i), "VMware") = 0 Then
				strMsg = strMsg & IPConfig.IPAddress(i)
				If i > 0 Then
					strMsg = strMsg & vbcrlf & VBTab
				End If
			End If
		End If
	Next
	End If
Next
Echo strMsg

Public IP.vbs

Based on script from howtogeek.com
I’m retrieving my public IP from ipify.org

Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://api.ipify.org", False
o.send
echo o.responseText

ISP Name.vbs

I’m using whoismyisp.org for this task

Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://www.whoismyisp.org", False
o.send
strid = o.responseText
Set myRegExp = New RegExp
With myRegExp
	.Pattern = "< p class=""isp"">(.*)< / p >" 'remove spaces before use :)
	.IgnoreCase = False
	.Global = False
End With
Set myMatches = myRegExp.Execute(strid)
 
Echo myMatches.Item(0).SubMatches(0)

IMPORTANT:
Because my regex contain HTML tags I added space between < and p. If you want to use my script remove this spaces!

14 thoughts on “BGInfo – Script for Local IP, Public IP and ISP Name”

  1. Thank you for these. I don’t know VBS and couldn’t have written them.

    I was curious if you found any issues with the ISP one. I keep getting an error for line 12, position 0, – invalid procedure call or argument.

    Either way, thank you.

  2. Hi,

    I updated my script. The problem was in the structure on the web page. they changed < h 1 > tag to < p > tag and my regex didn’t find any match…

    now it should work :)

  3. Hi Uroš Vovk,
    great script for BGInfo to show ISP. Thank you! I search for a script, that make BGInfo show the Country according to my WAN IP. E.G. if I have the WAN IP 185.183.107.242, BGInfo should tell me the according Country, in this example Austria. Do you know how to make this possible? Or do you know somebody who has such a script? Thanks a lot.

  4. Unfortunately, the display of the IP address is poor with several adapters, as they are displayed one after the other without any space between them. So you have a long chain of numbers without the necessary distinction. Should definitely be improved.

  5. Thank you for the scripts. I have been using them for more than a year and have it in a batch file and nothing has changed. However recently for ISPName.vbs
    I am getting ” Invalid procedure call or argument for “Echo myMatches.Item(0).SubMatches(0)”
    Must be some Windows update

  6. Hi, thank you for your work! Is it possible that ISP Name.vbs script doesn’t work anymore? Now I get the error code:

    BGInfo
    —————————
    Error evaluating scripted field ‘ISP Name’
    Microsoft VBScript run-time error
    Line 13, position 0
    Invalid procedure call or argument
    —————————
    OK
    —————————

  7. same here for ISP vbs :

    Error evaluating scripted field ‘ISP Name’
    Microsoft VBScript run-time error
    Line 13, position 0
    Invalid procedure call or argument

  8. Hi Uroš,

    Your script ISP Name.vbs worked like a charm, but now it looks like the html on “https://www.whoismyisp.org” has changed again.

    I get the same error as Giovanni.

    Can you please look at it?

    Kind regards,

    Jan

  9. Hi
    Many thanks for the script “ISP Name.vbs”. I used them for several months.
    It seems html page on target server changed, the script returns now empty name.

  10. The site changed. This script works for me.:
    ‘ bgISPName.vbs
    Dim o
    Set o = CreateObject(“MSXML2.XMLHTTP”)
    ‘ o.open “GET”, “https://api.ipify.org”, False
    ‘ o.send
    ‘ Set o = CreateObject(“MSXML2.XMLHTTP”)
    ‘ o.open “GET”, “https://www.whoismyisp.org”, False
    o.open “GET”, “https://www.whatismyisp.com”, False
    o.send
    strid = o.responseText
    Set myRegExp = New RegExp
    With myRegExp
    .Pattern = “(.*)” ‘remove spaces before use :)
    .IgnoreCase = False
    .Global = False
    End With
    Set myMatches = myRegExp.Execute(strid)

    ispname=myMatches.Item(0).SubMatches(0)

    wscript.echo myMatches.Item(0).SubMatches(0)
    wscript.echo ispname

  11. Updated version for ISP Name:

    Set o = CreateObject(“WinHttp.WinHttpRequest.5.1”)
    o.Open “GET”, “http://ip-api.com/json”, False
    o.Send
    strid = o.ResponseText

    Set myRegExp = New RegExp
    With myRegExp
    .Pattern = “””isp””:””([^””]*)”””
    .IgnoreCase = False
    .Global = False
    End With

    Set myMatches = myRegExp.Execute(strid)
    If myMatches.Count > 0 Then
    Echo myMatches.Item(0).SubMatches(0)
    Else
    Echo “ISP not found”
    End If

  12. Revised script for ISP name, this works as of December, 2024:

    Set o = CreateObject(“MSXML2.XMLHTTP”)
    o.open “GET”, “https://www.whatismyisp.com”, False
    o.send
    strid = o.responseText
    Set myRegExp = New RegExp
    With myRegExp
    .Pattern = “(.*)” ‘remove spaces before use :)
    .IgnoreCase = False
    .Global = False
    End With
    Set myMatches = myRegExp.Execute(strid)
    Echo myMatches.Item(0).SubMatches(0)

  13. Let me try again… comment board keeps removing the HTML tags even if you put spaces in them. For the script below to work, replace the uppercase letters LT with the less-than symbol and uppercase GT with the greater-than symbol typically used in HTML tags.

    Set o = CreateObject(“MSXML2.XMLHTTP”)
    o.open “GET”, “https://www.whatismyisp.com”, False
    o.send
    strid = o.responseText
    Set myRegExp = New RegExp
    With myRegExp
    .Pattern = “LTspan class=””block text-4xl””GT(.*)LT/spanGT”
    .IgnoreCase = False
    .Global = False
    End With
    Set myMatches = myRegExp.Execute(strid)
    Echo myMatches.Item(0).SubMatches(0)

Comments are closed.