Finding the IP address of a client 
Author Message
 Finding the IP address of a client

Hi Everyone,

How do I pull the local IP of a client PC?  We are using WSH 2.0 and
VBScript for their login scripts.  The problem is that I cannot pull
the IP from the registry due to the key type being REG_MULTI_SZ.  I
can pull other types of keys just fine using the RegRead function.

I have also tried the method on Ian's site (www.windows-script.com),
but I don't seem to have the right control registered for the
Mswinsock.winsock function.  What control should I use?

Any help would be greatly appreciated!!  Please feel free to email me
(just removed the obvious mistakes) or post your reply here.  Thanks
again for the help.

Brian



Sat, 07 Sep 2002 03:00:00 GMT  
 Finding the IP address of a client
Hey Ian,

Thanks for the quick response.

I really don't want to deploy any more software on client PCs.  We are
already sending out the scripting host files.  Is there a fix for the
RegRead error I mentioned?  I can pull REG_DWORD entries fine, but if
I try to pull out a REG_MULTI_SZ key, I get a "Type Mismatch" error
when the Wscript.Echo command runs.

I really don't mind pulling from the registry if it can save any more
time in downloads and updates.  Thanks again for the help.

Brian

On Wed, 22 Mar 2000 07:32:10 +1200, "Ian Morrish"

Quote:

>The MSWinsock control only works on a PC with some part of Visual Studio
>installed.
>Other options:
>Run IPConfig and pipe output to a file, then read in the file (messy but
>works)
>Use WMI (see example in my FAQ)

>Regards,
>Ian
>Senior Consultant     | MSDN Regional Director
>ADV E-Commerce    | Windows Script FAQ
>Advantage Group    | http://www.windows-script.com


>> Hi Everyone,

>> How do I pull the local IP of a client PC?  We are using WSH 2.0 and
>> VBscript for their login scripts.  The problem is that I cannot pull
>> the IP from the registry due to the key type being REG_MULTI_SZ.  I
>> can pull other types of keys just fine using the RegRead function.

>> I have also tried the method on Ian's site (www.windows-script.com),
>> but I don't seem to have the right control registered for the
>> Mswinsock.winsock function.  What control should I use?

>> Any help would be greatly appreciated!!  Please feel free to email me
>> (just removed the obvious mistakes) or post your reply here.  Thanks
>> again for the help.

>> Brian



Sat, 07 Sep 2002 03:00:00 GMT  
 Finding the IP address of a client
In the WSH 2.0 version of WScript.Shell, RegRead returns a variant array with each embedded string
already parsed for REG_MULTI_SZ values.  You can confirm this with Typename() which will return
"Variant()".  Each element is a variant of subtype String.  In WSH 1.0, you got a raw string with
null delimiters after each embedded string plus a null delimiter at the end and you had to do the
parsing yourself.

As an FYI, in WSH 2.0 you also get a variant array for REG_BINARY as well.  Each array element is a
variant of subtype Long.  In WSH 1.0 it was a native byte array (Typename ==> "Byte()" ) which was
sort of {*filter*} to parse.

Both are improvements on the RegRead side, but you still can't RegWrite either of these key types
except for a REG_BINARY that fits in a Long.

--
Michael Harris
MVP Scripting


Hi Everyone,

How do I pull the local IP of a client PC?  We are using WSH 2.0 and
VBscript for their login scripts.  The problem is that I cannot pull
the IP from the registry due to the key type being REG_MULTI_SZ.  I
can pull other types of keys just fine using the RegRead function.

I have also tried the method on Ian's site (www.windows-script.com),
but I don't seem to have the right control registered for the
Mswinsock.winsock function.  What control should I use?

Any help would be greatly appreciated!!  Please feel free to email me
(just removed the obvious mistakes) or post your reply here.  Thanks
again for the help.

Brian



Sat, 07 Sep 2002 03:00:00 GMT  
 Finding the IP address of a client
The MSWinsock control only works on a PC with some part of Visual Studio
installed.
Other options:
Run IPConfig and pipe output to a file, then read in the file (messy but
works)
Use WMI (see example in my FAQ)

Regards,
Ian
Senior Consultant     | MSDN Regional Director
ADV E-Commerce    | Windows Script FAQ
Advantage Group    | http://www.windows-script.com

Quote:
> Hi Everyone,

> How do I pull the local IP of a client PC?  We are using WSH 2.0 and
> VBscript for their login scripts.  The problem is that I cannot pull
> the IP from the registry due to the key type being REG_MULTI_SZ.  I
> can pull other types of keys just fine using the RegRead function.

> I have also tried the method on Ian's site (www.windows-script.com),
> but I don't seem to have the right control registered for the
> Mswinsock.winsock function.  What control should I use?

> Any help would be greatly appreciated!!  Please feel free to email me
> (just removed the obvious mistakes) or post your reply here.  Thanks
> again for the help.

> Brian



Sun, 08 Sep 2002 03:00:00 GMT  
 Finding the IP address of a client
Little correction for who, like me, use DHCP... ;)

Option Explicit
on error resume next

Dim  WSHShell

' Create Objects
Set WSHShell = WScript.CreateObject("WScript.Shell")

call main()

' FUNCTIONS HERE
Sub GetIP
        Dim CardType
        Dim MyIP
        Dim booDHCP
        Dim i

        'What Kind of Card is it
        CardType = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\1\ServiceName")

        booDHCP = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\EnableDHCP")

        if booDHCP then
                MyIP = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\DHCPIPAddress")
                WScript.Echo MyIP
        else
                MyIP = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\IPAddress")
                for i = 0 to UBOUND(MyIP)
                        WScript.Echo MyIP(i)
                next
        end if

end Sub

'Run it From Here
Sub main()
GetIP()
End Sub

.Enjoy.
Legolas

Quote:


> Hi Everyone,

> How do I pull the local IP of a client PC?  We are using WSH 2.0 and

> VBscript for their login scripts.  The problem is that I cannot pull

> the IP from the registry due to the key type being REG_MULTI_SZ.  I
> can pull other types of keys just fine using the RegRead function.

> I have also tried the method on Ian's site (www.windows-script.com),

> but I don't seem to have the right control registered for the
> Mswinsock.winsock function.  What control should I use?

> Any help would be greatly appreciated!!  Please feel free to email me
> (just removed the obvious mistakes) or post your reply here.  Thanks

> again for the help.

> > Brian



Sun, 08 Sep 2002 03:00:00 GMT  
 Finding the IP address of a client
Muchas Gracias to everyone!!  It works like a charm!

Brian



Quote:
>Little correction for who, like me, use DHCP... ;)

>Option Explicit
>on error resume next

>Dim  WSHShell

>' Create Objects
>Set WSHShell = WScript.CreateObject("WScript.Shell")

>call main()

>' FUNCTIONS HERE
>Sub GetIP
>    Dim CardType
>    Dim MyIP
>    Dim booDHCP
>    Dim i

>    'What Kind of Card is it
>    CardType = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\1\ServiceName")

>    booDHCP = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\EnableDHCP")

>    if booDHCP then
>            MyIP = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\DHCPIPAddress")
>            WScript.Echo MyIP
>    else
>            MyIP = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\IPAddress")
>            for i = 0 to UBOUND(MyIP)
>                    WScript.Echo MyIP(i)
>            next
>    end if

>end Sub

>'Run it From Here
>Sub main()
>GetIP()
>End Sub

>.Enjoy.
>Legolas



>> Hi Everyone,

>> How do I pull the local IP of a client PC?  We are using WSH 2.0 and

>> VBscript for their login scripts.  The problem is that I cannot pull

>> the IP from the registry due to the key type being REG_MULTI_SZ.  I
>> can pull other types of keys just fine using the RegRead function.

>> I have also tried the method on Ian's site (www.windows-script.com),

>> but I don't seem to have the right control registered for the
>> Mswinsock.winsock function.  What control should I use?

>> Any help would be greatly appreciated!!  Please feel free to email me
>> (just removed the obvious mistakes) or post your reply here.  Thanks

>> again for the help.

>> > Brian



Sun, 08 Sep 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. finding a client's ip address

2. Obtaining client IP address client side

3. Obtaining client IP address client side

4. Obtaining client IP address client side

5. Getting Client's IP Address on Client Side

6. Find out IP address of URL.

7. Finding my IP Address

8. finding ip addresses

9. Find IP address for a given Server Name

10. Find IP address of a remote host

11. Finding my IP Address

12. Detecting IP Clients Address

 

 
Powered by phpBB® Forum Software