Submitted By: Anonymous Submission

Lists the subnet your computer is in.

Visual Basic
Edit|Remove
Set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
  ("select IPAddress, DnsDomain from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
 If InStr(IPConfig.DnsDomain, "MYDNSDOMAINNAME") Then
  For i=LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
   myIP = IPConfig.IPAddress(i)

  Next
 End If
Next

'get location by subnet

tmpIPString = Split (myIP,".",4)
Subnet = tmpIPString(2)
Wscript.echo "My Subnet is " & Subnet