'subnet.vbs - displays the subnet for the computer's (or given) IP ' addresses and subnet masks Set Arguments = Wscript.Arguments If Wscript.Arguments.Count=2 Then SubNetIT Arguments(0), Arguments(1) Wscript.Echo "" Else Set loc = CreateObject( "WbemScripting.SWbemLocator" ) Set WbemServices = loc.ConnectServer( ,"root\cimv2" ) Set Adapters=WbemServices.ExecQuery( "Select * FROM" & _ " Win32_NetworkAdapterConfiguration" ) For Each Adapter in Adapters If NOT IsNull( Adapter.IPAddress) Then WScript.Echo "Description: ", Adapter.Description SubNetIt Adapter.IPAddress(0), Adapter.IPSubnet(0) WScript.Echo "" End If Next WScript.Echo "You can also specify an address and subnet mask as " & _ "parameters to this script." WScript.Echo "" End If WScript.Echo "At least one subnet must be a site's boundary for this computer" WScript.Echo "to be assigned as a client." Sub SubNetIt( Address, Subnet ) WScript.Echo "IP address: ", Address WScript.Echo "subnet mask: ", Subnet dim addressbytes(4) dim subnetmaskbytes(4) i=0 period = 1 while period<>len( address ) + 2 prevperiod=period period = instr( period+1, address, "." ) + 1 if period = 1 then period = len( address ) + 2 addressbyte = mid( address, prevperiod, period-prevperiod-1 ) addressbytes(i)=addressbyte i=i+1 wend i=0 period = 1 while period<>len( subnet ) + 2 prevperiod=period period = instr( period+1, subnet, "." ) + 1 if period = 1 then period = len( subnet ) + 2 subnetmaskbyte = mid( subnet, prevperiod, period-prevperiod-1) subnetmaskbytes(i)=subnetmaskbyte i=i+1 wend subnet="" for i=0 to 3 subnet = subnet & (addressbytes(i) AND subnetmaskbytes(i)) & "." next subnet = left( subnet, len(subnet)-1 ) WScript.Echo "subnet: ", subnet End Sub