VBscript Subnet 
Author Message
 VBscript Subnet

I got the following script from a website and it works perfect but I would
like to change it
from getting the ipaddress to subnet. What is the syntax for subnet
(IPConfig.Subnet)?
Any help would be appreciated.

Dim IP
set IPConfigSet =
GetObject("winmgmts:{impersonationLevel=impersonate}").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



Fri, 18 Feb 2005 02:53:50 GMT  
 VBscript Subnet

Quote:

> I got the following script from a website and it works perfect but I would
> like to change it
> from getting the ipaddress to subnet. What is the syntax for subnet
> (IPConfig.Subnet)?

Hi

Win32_NetworkAdapterConfiguration
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_networkadapt...

List IP addresses and subnet masks:

Set oNICSet = GetObject _
   ("winmgmts:{impersonationLevel=impersonate}") _
   .InstancesOf("Win32_NetworkAdapterConfiguration")

For Each oNIC In oNICSet
  If oNIC.IPEnabled Then
    If Not IsNull(oNIC.IPAddress) Then
      For i=LBound(oNIC.IPAddress) To UBound(oNIC.IPAddress)
        WScript.Echo oNIC.IPAddress(i)
      Next
      For i=LBound(oNIC.IPSubnet) To UBound(oNIC.IPSubnet)
      WScript.Echo oNIC.IPSubnet(i)
      Next
    End If
  End If
Next

--
torgeir



Fri, 18 Feb 2005 03:46:26 GMT  
 VBscript Subnet
replace all IPAddress with IPSubnet
Quote:

>I got the following script from a website and it works perfect but I would
>like to change it
>from getting the ipaddress to subnet. What is the syntax for subnet
>(IPConfig.Subnet)?
>Any help would be appreciated.

>Dim IP
>set IPConfigSet =
>GetObject("winmgmts:{impersonationLevel=impersonate}").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



Fri, 18 Feb 2005 04:26:17 GMT  
 VBscript Subnet

Quote:

> replace all IPAddress with IPSubnet

Hi

That will not work, will end up in this error message:

Microsoft VBScript runtime error: Object doesn't support this property or
method: 'IPConfig.IPSubnet'

You need to attach to the WMI instance of the Win32_NetworkAdapterConfiguration
to get to the IPSubnet property, see my post.

--
torgeir



Fri, 18 Feb 2005 04:41:02 GMT  
 VBscript Subnet
Dim IP
set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery ("select IPSubnet
from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

for each IPConfig in IPConfigSet
if Not IsNull(IPConfig.IPSubnet) then
for i=LBound(IPConfig.IPSubnet) to UBound(IPConfig.IPSubnet)
        WScript.Echo IPConfig.IPSubnet(i)
Next
End if
Next

'255.255.255.0
'make sure you select IPSubnet

Quote:


>> replace all IPAddress with IPSubnet

>Hi

>That will not work, will end up in this error message:

>Microsoft VBScript runtime error: Object doesn't support this property or
>method: 'IPConfig.IPSubnet'

>You need to attach to the WMI instance of the Win32_NetworkAdapterConfiguration
>to get to the IPSubnet property, see my post.



Fri, 18 Feb 2005 05:03:47 GMT  
 VBscript Subnet

Quote:

> Dim IP
> set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery ("select IPSubnet
> from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

> for each IPConfig in IPConfigSet
> if Not IsNull(IPConfig.IPSubnet) then
> for i=LBound(IPConfig.IPSubnet) to UBound(IPConfig.IPSubnet)
>         WScript.Echo IPConfig.IPSubnet(i)
> Next
> End if
> Next

> '255.255.255.0
> 'make sure you select IPSubnet

Hi

Ahh, of course, I missed that one (I'm used to that most people is using * in the select statement ;-)

--
torgeir



Fri, 18 Feb 2005 05:09:40 GMT  
 VBscript Subnet
OMG!!

I thought I tried that! Thanks guys


Quote:

> > Dim IP
> > set IPConfigSet =

GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery ("select
IPSubnet
Quote:
> > from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

> > for each IPConfig in IPConfigSet
> > if Not IsNull(IPConfig.IPSubnet) then
> > for i=LBound(IPConfig.IPSubnet) to UBound(IPConfig.IPSubnet)
> >         WScript.Echo IPConfig.IPSubnet(i)
> > Next
> > End if
> > Next

> > '255.255.255.0
> > 'make sure you select IPSubnet

> Hi

> Ahh, of course, I missed that one (I'm used to that most people is using *

in the select statement ;-)

- Show quoted text -

Quote:

> --
> torgeir



Fri, 18 Feb 2005 07:20:17 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Get DHCP subnet

2. How to change Subnet mask with NetSh?

3. How to generate a list of hostnames in a given ip-subnet

4. subnet check

5. obtaining the subnet

6. DNS WINS and Subnet info.

7. Find the Subnet Mask on NT

8. Setting subnet mask a gateway with wsh

9. SCRIPT: Getting System Times on a Class C Subnet via WMI

10. Subnet check

11. Does an IP address belong to this subnet?

12. How get subnet mask

 

 
Powered by phpBB® Forum Software