Re: Gathering Workstation IP Address



"Tired Tech" <TiredHATESPAMTech@xxxxxxxxx> wrote in message
news:TiredHATESPAMTech-D6A69F.01283029012006@xxxxxxxxxxxxxxxxxxx
> After searching through the registry on WinXP, I could not find an ASCII
> reference for IP address. This was such an easy task with WinNT, yet I
> guess it's an encoded value now on WinXP. Anyway, I am using the
> following code to gather IP addresses:
>
> -----
> 'Launch IPCONFIG
> Set ipExec = WSH.Exec("ipconfig.exe")
>
> 'Go to the correct line of returned output from IPCONFIG
> for i = 0 to 6
> ipExec.StdOut.SkipLine
> next
>
> 'Now at the right spot, read the entire line
> strIPinfo = ipExec.StdOut.ReadLine()
>
> 'Gives me the IP address
> strIPinfo = Mid(strIPinfo,45)
> -----
>
> While the above works for me, I was hoping there was an object similar
> to Wscript.Network that already gathers this information. Besides, the
> above code splashes a command window on the screen every so briefly. It
> would be nice to simplify things and remove the command window kludge.
>
> Joe
>
> --
> Tired Tech

Try using WMI. Here is GetIP.vbs:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress 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)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next


B-Mann



.



Relevant Pages

  • Re: Sudden loss of connectivity?
    ... All running winXP and all working fine until couple days ... Ipconfig localhost works. ... plugged USB adapter into same laptop and ... >(or winsock?), but don't know where to go from here. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Getmac Command
    ... Besides, as we can use IPCONFIG to get the MAC address, I would like to ... There is no getmac.exe command in WinXP and if you ...
    (microsoft.public.windowsxp.general)
  • Re: Getmac Command
    ... Besides, as we can use IPCONFIG to get the MAC address, I would like to ... There is no getmac.exe command in WinXP and if you ...
    (microsoft.public.windowsxp.general)
  • RE: IPCONFIG ERROR
    ... That is an Win98 & ME app only. ... You have to use ipconfig from the command prompt in winxp. ...
    (microsoft.public.windowsxp.general)
  • Re: help me
    ... type: ipconfig ... please give me the compatible model of winipcfg in winxp. ...
    (microsoft.public.windowsxp.general)