From: tree leafs on
Hi,
I am looking for some startup script that can detect PC's IP subnet.
Thanks in advance.


From: Pegasus [MVP] on


"tree leafs" <treeleafs(a)hotmail.com> wrote in message
news:#v2zCWC7KHA.5808(a)TK2MSFTNGP02.phx.gbl...
> Hi,
> I am looking for some startup script that can detect PC's IP subnet.
> Thanks in advance.

This code fragment uses WMI to return the PC's IP address. You can easily
extract the subnet.

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True")

For Each objNetAdapter In colNetAdapters
WScript.Echo "IP_Address=" & objNetAdapter.IPAddress(0)
Next