2

I'm looking for a solution to grab people's internal ip addresses in IE (not using java or java applets). The equivalent in Java looks like that:

this.sock.bind(new java.net.InetSocketAddress('0.0.0.0', 0));
this.sock.connect(new java.net.InetSocketAddress(document.domain, (!document.location.port)?80:document.location.port));
return this.sock.getLocalAddress().getHostAddress();

Is that something possible in vbscript or jscript? Could you provide me with an example?

Thanks for your time.

Benjamin
  • 617
  • 13
  • 27
  • Half duplicate of [this SO question](http://stackoverflow.com/questions/391979/get-client-ip-using-just-javascript) – Marcus Whybrow Nov 22 '10 at 01:53
  • Yes except this guy is looking into doing it with java. I'm looking for an alternative that works on IE without using applets. – Benjamin Nov 22 '10 at 02:53

2 Answers2

1

You can not get internal IP with JavaScript.

This looks like something you'll need an ActiveX control for, if it is possible.

alex
  • 479,566
  • 201
  • 878
  • 984
  • You can call java from javascript in FF, Chrome and Safari. Check this out: http://code.google.com/p/beef/source/browse/trunk/modules/beefjs/net/local.js – Benjamin Nov 22 '10 at 02:54
1

I think that depending on the security settings in IE you might be able to use WMI. If so you could just use the Win32_NetworkAdapterConfiguration and it's IPAddress property.

The following sample in vbscript:

strComputer = "."
Set objWMIService = GetObject( _ 
    "winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
    ("Select IPAddress from Win32_NetworkAdapterConfiguration ")

For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then 
        For i=LBound(IPConfig.IPAddress) _
            to UBound(IPConfig.IPAddress)
                WScript.Echo IPConfig.IPAddress(i)
        Next
    End If
Next

Is taken from this MSDN page.

Hans Olsson
  • 54,199
  • 15
  • 94
  • 116