• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

script to determine PC's IP subnet


Pegasus [MVP]

"tree leafs" <treeleafs@newsgroup> wrote in message

> 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)

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)