IP Address 
Author Message
 IP Address

is there simple piece of code that can be used in a VBScript to obtain the
local ip address? surely there is a simple command that will return this
value. thanks


Thu, 20 Nov 2003 00:50:24 GMT  
 IP Address
<%=(Request.ServerVariables("Remote_Addr"))%>

Jim


Quote:
> is there simple piece of code that can be used in a vbscript to obtain the
> local ip address? surely there is a simple command that will return this
> value. thanks



Thu, 20 Nov 2003 02:01:18 GMT  
 IP Address
i also need this code, but i need it for when a user runs my vb login
script, so this will not work. it also needs to work on win95 right through
to win2000. thanks.

Steve



Thu, 20 Nov 2003 05:47:06 GMT  
 IP Address
I have never tested this on Win 9X, but you could look at using WMI.  Below
is a basic example of how you use WMI to get an IP config locally or
remotely.  Edit and configure and required.

If it doesn't work on Win 9X maybe you should upgrade or plan to migrate to
Window 2K or XP.  Personally, I could never go back...

John

C:\Data\WMI_notes\WMI>IPconfig.vbs maui
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

IP Addresses For kauai
--------------------------------------
Adapter Description 3Com EtherLink PCI

MACAddress 00:AD:5A:A4:D1:B2

                202.10.120.106
                255.255.255.248

Default Gateways:

                202.10.120.105
Adapter Description ELNK3 Ethernet Adapter

MACAddress 00:30:BF:3E:79:2B

**************************************START FILE.VBS
Dim winmgt

remotely
'assumes wmi installed and right etc to access etc.

If WScript.Arguments.Count <> 1 Then

 WScript.Echo "This Script Expects A Server Name Parameter!"
 WScript.Quit

End If

ServerName = WScript.Arguments.Item(0)

Set winmgt    = GetObject("winmgmts://" & ServerName)

WScript.Echo "IP Addresses For " & ServerName
WScript.Echo "--------------------------------------"
WScript.Echo GetIPs

'******************************************
Function GetIPs()
'******************************************

If ScriptDebug Then On Error Resume Next

Dim Adapters, Adapter, addr, i

Set Adapters = winmgt.Execquery("Select * from
Win32_NetworkAdapterConfiguration")

For Each Adapter in Adapters

If Adapter.IPEnabled Then

WScript.Echo "Adapter Description " & Adapter.Description
WScript.Echo ""
WScript.Echo "MACAddress " & Adapter.MACAddress
WScript.Echo ""
 If IsArray(Adapter.IPAddress) Then

  i = 0

  For Each IP in Adapter.IPAddress

   CheckIP = IP
   WScript.Echo VBTab & VBTab & CheckIP
   WScript.Echo VBTab & VBTab & Adapter.IPSubnet(i)

   i = i + 1

  Next

 End If

WScript.Echo ""

If IsArray(Adapter.DefaultIPGateway) Then

WScript.Echo ""
WScript.Echo "Default Gateways:"
WScript.Echo ""

 For Each Gateway in Adapter.DefaultIPGateway

  WScript.Echo VBTab & VBTab & Gateway

 Next

End If

Else

'WScript.Echo "Adapter " & Adapter.Caption & " - " & Adapter.Description & "
Doesn't have IP Enabled!"

End If

Next

CheckIP = False

End Function

**************************************END FILE.VBS


Quote:
> is there simple piece of code that can be used in a vbscript to obtain the
> local ip address? surely there is a simple command that will return this
> value. thanks



Fri, 21 Nov 2003 05:57:57 GMT  
 IP Address

The hard part about this is that the registry stores the IP in a key under
an unpredictable GUID.  I actually wrote a script that redirects IPconfig to
a text file and then extracts it out with some string commands.  It is
WAAAAY ugly but it works.

If you're interested I'll send it to you.  (I'll have to dig it up)

Quote:

> i also need this code, but i need it for when a user runs my vb login
> script, so this will not work. it also needs to work on win95 right
through
> to win2000. thanks.

> Steve



Sat, 27 Dec 2003 07:55:17 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. changing of IP-address and other IP parameters

2. changing of IP-address and other IP parameters

3. VBscript for IP Address, Mac Address, Username

4. How to get IP my IP address

5. TCP/IP IP address and multiple adapters

6. Network adapter question: how to put ip address and MAC addresses together

7. Mapping IP address to MAC address (VB5.0)

8. IP Address & MAC Address

9. : TCP/IP address via email address

10. MAC Address to IP Address

11. MAC Address to IP Address

12. MAC address --> IP address

 

 
Powered by phpBB® Forum Software