is it possible to get the IP address of a client via VBS and check it
against an IP range such as the following IP pool
172.16.172.0/255.255.252.0 that is from 172.16.172.1 to 172.16.175.254

Whats the best way to do such a check...........

Thanks

Momo

Re: getting client IP address ....... by Momo

Momo
Mon Nov 07 06:19:05 CST 2005

Maybe I should clarify that.......... how can I do a check to say that
if the IP address is not in the specified range pool of
172.16.172.0/255.255.252.0 that is from 172.16.172.1 to 172.16.175.254
then do something.....

or alternative if IP address range is within 10.150.xxx.xxx do
something......

Thanks very much.....

Momo


Re: getting client IP address ....... by Momo

Momo
Mon Nov 07 06:21:42 CST 2005

Maybe I should clarify that.......... how can I do a check to say that
if the IP address is not in the specified range pool of
172.16.172.0/255.255.252.0 that is from 172.16.172.1 to 172.16.175.254
then do something.....

or alternative if IP address range is within 10.150.xxx.xxx do
something......

Thanks very much.....

Momo


Re: getting client IP address ....... by Roland

Roland
Mon Nov 07 12:30:54 CST 2005

"Momo" wrote in message
news:1131358391.227276.29980@o13g2000cwo.googlegroups.com...
: is it possible to get the IP address of a client via VBS and check it
: against an IP range such as the following IP pool
: 172.16.172.0/255.255.252.0 that is from 172.16.172.1 to 172.16.175.254

Generally when a .vbs file is being run it is being run locally. Are you
wanting to get the IP address of the client who is running this script or do
you want your script to resolve the IP address of a remote system based upon
a NetBIOS name or FQDN?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: getting client IP address ....... by Momo

Momo
Mon Nov 07 19:02:18 CST 2005

I'd like to get the local IP address oc the client and do a comparison
and do a comparion of its IP to check that its range is within the
range 10.150.122.x.x mask 255.255.248.0 and if so do something using an
if.

I just need to know how to do the IP address comparison..............

Cheers

Momo


Re: getting client IP address ....... by Momo

Momo
Mon Nov 07 19:14:25 CST 2005

Additionally since I doing a check on clients that'll be using VPN, the
clients will have multiple IP addresses. so what I need to do is check
if any adapters have an IP within the range of 10.150.122.x.x mask
255.255.248.0.

Thank you very much


Re: getting client IP address ....... by Momo

Momo
Mon Nov 07 19:15:05 CST 2005

Additionally since I doing a check on clients that'll be using VPN, the
clients will have multiple IP addresses. so what I need to do is check
if any adapters have an IP within the range of 10.150.122.x.x mask
255.255.248.0.

Thank you very much


Re: getting client IP address ....... by Roland

Roland
Tue Nov 08 14:54:55 CST 2005

"Momo" wrote in message
news:1131411738.466207.136390@g49g2000cwa.googlegroups.com...
: I'd like to get the local IP address oc the client and do a comparison
: and do a comparion of its IP to check that its range is within the
: range 10.150.122.x.x mask 255.255.248.0 and if so do something using an
: if.
:
: I just need to know how to do the IP address comparison..............

Let me try to ask you differently...

Who runs the script? You on your local drive that executes against a remote
system or someone on a remote system looking at their own IP address?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: getting client IP address ....... by Momo

Momo
Tue Nov 08 18:57:46 CST 2005

It'll be the local system checking its own IP address against a range
eg. want to check the IP address of itself whether any of its IPs fall
into the range 10.150.122.x.x mask 255.255.248.0. Some workstations
will have 3 IP addresses because using VPN ie. 192.168.2.2/24,
203.198.250.91 and 172.16.173.256.

The script will also be run locally on the machine as
well..............

Check whether any of the addresses it has falls into the 10.150.122.x.x
mask 255.255.248.0 range........


Thanks for your help Roland.............

Cheers.....


Re: getting client IP address ....... by Momo

Momo
Wed Nov 09 01:55:24 CST 2005

I've managed to get it half working I think..... using snippets of code
here and there................... but I found in some cases if the
workstation is on a local LAN it may get the 10.150.x.x address and
another 0.0.0.0 (I think its due to some machines having a particular
VPN client installed.)

So is there anyway I can tell it to ignore the 0.0.0.0 IP address.....?

Dim CurrentAddress, WshShell, Linkstatus
Set WshShell = Createobject("WScript.shell")

Linkstatus=1
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _
("Select * 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)
CurrentAddress=IpConfig.IPAddress(i)
WScript.Echo "Current Address is " & CurrentAddress
If Left(CurrentAddress, 6)="10.150" Then
WScript.Echo "Workstation is on network"
Linkstatus=0
WScript.Echo "Linkstatus= " & Linkstatus
Else
WScript.Echo "WAN Dial-up link"
Linkstatus=1
WScript.Echo "Linkstatus= " & Linkstatus
End If
Next
End If
Next

If Linkstatus=0 Then
WScript.Echo "Workstation is on LAN, commencing migration process...."
Else
WScript.Echo "Workstation is Dial-up VPN, aborting migration..."
End If


Additionally is there anyway of telling it to stop execution if it
detects a Dial-up link - what I mean is end the script..............
since there's also a whole chunk of code below to be executed if the
machine falls within the 10.150.x.x range......

Thanks alot...............


Re: getting client IP address ....... by Roland

Roland
Wed Nov 09 04:57:36 CST 2005

"Momo" <louey-3@excite.com> wrote in message
news:1131522924.116710.182900@o13g2000cwo.googlegroups.com...
: I've managed to get it half working I think..... using snippets of code
: here and there................... but I found in some cases if the
: workstation is on a local LAN it may get the 10.150.x.x address and
: another 0.0.0.0 (I think its due to some machines having a particular
: VPN client installed.)
:
: So is there anyway I can tell it to ignore the 0.0.0.0 IP address.....?
:
: Dim CurrentAddress, WshShell, Linkstatus
: Set WshShell = Createobject("WScript.shell")
:
: Linkstatus=1
: strComputer = "."
: Set objWMIService = GetObject("winmgmts:" _
: & "{impersonationLevel=impersonate}!\\" & strComputer &
: "\root\cimv2")
:
: Set IPConfigSet = objWMIService.ExecQuery _
: ("Select * 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)
: CurrentAddress=IpConfig.IPAddress(i)
: WScript.Echo "Current Address is " & CurrentAddress
: If Left(CurrentAddress, 6)="10.150" Then
: WScript.Echo "Workstation is on network"
: Linkstatus=0
: WScript.Echo "Linkstatus= " & Linkstatus
: Else
: WScript.Echo "WAN Dial-up link"
: Linkstatus=1
: WScript.Echo "Linkstatus= " & Linkstatus
: End If
: Next
: End If
: Next
:
: If Linkstatus=0 Then
: WScript.Echo "Workstation is on LAN, commencing migration process...."
: Else
: WScript.Echo "Workstation is Dial-up VPN, aborting migration..."
: End If
:
:
: Additionally is there anyway of telling it to stop execution if it
: detects a Dial-up link - what I mean is end the script..............
: since there's also a whole chunk of code below to be executed if the
: machine falls within the 10.150.x.x range......

Try this:

Option Explicit
Dim CurrentAddress, strComputer, objWMIService, IPConfigSet, IPConfig, i,
match, low, high
low = "172.16.172.1"
high = "172.16.175.254"
strComputer = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery ("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled=true")

if IPConfigSet.Count > 0 then
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i = 0 to UBound(IPConfig.IPAddress)
CurrentAddress=IpConfig.IPAddress(i)
if CurrentAddress >= low and CurrentAddress <= high then
migrate CurrentAddress
' exit for ' uncomment this line if you only need one valid range
else
prt CurrentAddress & " is out of migration IP range."
End If
Next
End If
Next
end if

prt "Migration process complete!"

sub migrate(CurrentAddress)
' put migration code here
prt "Migrating " & CurrentAddress & "..."
end sub

sub prt(str)
wscript.echo str
end sub



Re: getting client IP address ....... by Momo

Momo
Wed Nov 09 06:17:56 CST 2005

Roland,

Thanks very much for that.......... I'll have a look at
it.............

>From what I see......... the script checks the IP address to see if
there in the specificed upper and lower range, is that correct....

Cheers

Thanks


Re: getting client IP address ....... by Momo

Momo
Wed Nov 09 06:18:01 CST 2005

Roland,

Thanks very much for that.......... I'll have a look at
it.............

>From what I see......... the script checks the IP address to see if
there in the specificed upper and lower range, is that correct....

Cheers

Thanks


Re: getting client IP address ....... by Roland

Roland
Wed Nov 09 20:22:12 CST 2005

"Momo" <louey-3@excite.com> wrote in message
news:1131538676.379965.73750@f14g2000cwb.googlegroups.com...
: Roland,
:
: Thanks very much for that.......... I'll have a look at
: it.............
:
: >From what I see......... the script checks the IP address to see if
: there in the specificed upper and lower range, is that correct....

Yes, that's correct.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: getting client IP address ....... by Momo

Momo
Thu Nov 10 09:27:05 CST 2005

Roland,

Just found out that I'll probably need to check 6-7 ranges like
10.150.x.x-10.150.x.x, 170.150.x.x-170.150.x.x, 192.168.x.x-192.168.x.x
........... ;-(
So I'll need to define 6 to 7 IP low/high values and check again each
range..... should I use a case statement? Instead of the "If then
Else", will that server better in such situation......

if CurrentAddress >= low and CurrentAddress <= high then
migrate CurrentAddress
' exit for ' uncomment this line if you only need one valid
range
else
prt CurrentAddress & " is out of migration IP range."
End If


Cheers sorry for being so troublesome.........


Re: getting client IP address ....... by Roland

Roland
Fri Nov 11 03:18:31 CST 2005

"Momo" wrote in message
news:1131636425.585573.211180@o13g2000cwo.googlegroups.com...
: Roland,
:
: Just found out that I'll probably need to check 6-7 ranges like
: 10.150.x.x-10.150.x.x, 170.150.x.x-170.150.x.x, 192.168.x.x-192.168.x.x
: ........... ;-(
: So I'll need to define 6 to 7 IP low/high values and check again each
: range..... should I use a case statement? Instead of the "If then
: Else", will that server better in such situation......
:
: if CurrentAddress >= low and CurrentAddress <= high then
: migrate CurrentAddress
: ' exit for ' uncomment this line if you only need one valid
: range
: else
: prt CurrentAddress & " is out of migration IP range."
: End If

Ok, the way this works is the first SELECT..CASE needs to be in order from
highest to lowest. Make sure they're in order when you add more ranges.

Then just match that with the next SELECT..CASE and you should be fine.

Source:

Option Explicit
Dim CurrentAddress, strComputer, objWMIService, IPConfigSet, IPConfig, i,
msg, range, ok
msg = "Migration process complete!"
ok = true
strComputer = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery ("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled=true")

if IPConfigSet.Count > 0 then
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i = 0 to UBound(IPConfig.IPAddress)
CurrentAddress=IpConfig.IPAddress(i)
select case true
case CurrentAddress >= "192.168.0.1"
range = "a"
case CurrentAddress >= "170.150.0.1"
range = "b"
case CurrentAddress >= "10.150.0.1"
range = "c"
case else
msg = "out of migration IP range."
ok = false
end select
if ok then
select case range
case "a"
if CurrentAddress <= "192.168.255.254" then migrate
CurrentAddress
case "b"
if CurrentAddress <= "170.150.255.254" then migrate
CurrentAddress
case "c"
if CurrentAddress <= "10.150.255.254" then migrate
CurrentAddress
case else
msg = "out of migration IP range."
end select
end if
Next
End If
Next
end if

prt msg

sub migrate(CurrentAddress)
' put migration code here
prt "Migrating " & CurrentAddress & "..."
end sub

sub prt(str)
wscript.echo str
end sub

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: getting client IP address ....... by Momo

Momo
Fri Nov 11 10:16:18 CST 2005

Roland your a real start ^-^

Thanks for the great HELP............. I'll try this out and let you
know of the gd news............

Cheers..........


Re: getting client IP address ....... by Momo

Momo
Sat Nov 12 04:27:43 CST 2005

I checked the script with an IP address of 192.168.1.100, and
accordingly if I'm reading correctly it should enumerate to

case CurrentAddress >= "192.168.0.1 "
range "a"

so it should go to Case "a" and check the upper range

Case "a"
If CurrentAddress <= "192.168.255.254" Then migrate
CurrentAddress

and then call the migrate, but from what I'm seeing what happens is
that when its checking the lower range it doesn't fall into any of the
lower ranges and goes straight to the

Case Else
msg = "Failed lower boundry out of migration IP range."
ok = False

and sets ok=false and stops the migration............ any hints where
the problem is............

Thanks so much in advance........


Re: getting client IP address ....... by Momo

Momo
Sat Nov 12 05:02:23 CST 2005

I'm not sure if I'm doing anything wrong, but I pasted and ran the code
with my workstation IP of 192.168.1.100. Accoridingly if I'm reading
the script correctly, it shoul enumerate to range "a", which then
checks if the IP is less than

Case "a"
If CurrentAddress <= "192.168.255.254" Then migrate CurrentAddress

However it seems to be jumping staight to the end and going straight
to:
Case Else
msg = "out of migration IP range."
ok = false

and not doing the migration......... any hints why?

Cheers thanks alot..........


Re: getting client IP address ....... by Roland

Roland
Sun Nov 13 01:24:38 CST 2005

"Momo" <louey-3@excite.com> wrote in message
news:1131791263.078429.150770@o13g2000cwo.googlegroups.com...
:I checked the script with an IP address of 192.168.1.100, and
: accordingly if I'm reading correctly it should enumerate to
:
: case CurrentAddress >= "192.168.0.1 "
: range "a"
:
: so it should go to Case "a" and check the upper range
:
: Case "a"
: If CurrentAddress <= "192.168.255.254" Then migrate
: CurrentAddress
:
: and then call the migrate, but from what I'm seeing what happens is
: that when its checking the lower range it doesn't fall into any of the
: lower ranges and goes straight to the
:
: Case Else
: msg = "Failed lower boundry out of migration IP range."
: ok = False
:
: and sets ok=false and stops the migration............ any hints where
: the problem is............

Can you show me the current source code you have?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: getting client IP address ....... by Momo

Momo
Sun Nov 13 04:09:22 CST 2005

Attached here it is.......... all I did was copy the source you
provided and added a few wscript.echo commands so that I could do some
logging. I'm running the script with a worksation IP of 192.168.1.100.
And its giving me an "Out of IP range" message........

Thank you so much............



Option Explicit
Dim CurrentAddress, strComputer, objWMIService, IPConfigSet, IPConfig,
i, msg, range, ok
msg = "Migration process complete!"
ok = True
WScript.Echo "Initial value of ok is: " & ok
strComputer = "."


Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer
& "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery ("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled=true")


If IPConfigSet.Count > 0 then
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i = 0 to UBound(IPConfig.IPAddress)
CurrentAddress=IpConfig.IPAddress(i)
WScript.Echo "Checking lower boundry"
select Case True
case CurrentAddress >= "192.168.0.1 "
WScript.Echo "Case 1 value of ok is " & ok
WScript.Echo CurrentAddress
range = "a"
case CurrentAddress >= "170.150.0.1"
range = "b"
case CurrentAddress >= "10.150.0.1"
range = "c"
Case Else
msg = "Failed lower boundry out of migration IP range."
ok = False
end Select
WScript.Echo "Value of ok is: " & ok
if ok Then
WScript.Echo "Checking upper boundry"
select case range
Case "a"
If CurrentAddress <= "192.168.255.254" Then migrate
CurrentAddress
WScript.Echo CurrentAddress
case "b"
if CurrentAddress <= "170.150.255.254" then migrate
CurrentAddress
case "c"
if CurrentAddress <= "10.150.255.254" then migrate
CurrentAddress
case else
msg = "out of migration IP range."
end select
end if
Next
End If
Next
End if


prt msg


Sub migrate(CurrentAddress)
' put migration code here
prt "Migrating " & CurrentAddress & "..."
End sub


Sub prt(str)
wscript.echo str
End sub


Re: getting client IP address ....... by Roland

Roland
Wed Nov 16 14:56:10 CST 2005

"Momo" wrote in message
news:1131876562.743001.270680@z14g2000cwz.googlegroups.com...
: Attached here it is.......... all I did was copy the source you
: provided and added a few wscript.echo commands so that I could do some
: logging. I'm running the script with a worksation IP of 192.168.1.100.
: And its giving me an "Out of IP range" message........
:
: Thank you so much............
:
:
:
: Option Explicit
: Dim CurrentAddress, strComputer, objWMIService, IPConfigSet, IPConfig,
: i, msg, range, ok
: msg = "Migration process complete!"
: ok = True
: WScript.Echo "Initial value of ok is: " & ok
: strComputer = "."
:
:
: Set objWMIService =
: GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer
: & "\root\cimv2")
: Set IPConfigSet = objWMIService.ExecQuery ("SELECT * FROM
: Win32_NetworkAdapterConfiguration WHERE IPEnabled=true")
:
:
: If IPConfigSet.Count > 0 then
: For Each IPConfig in IPConfigSet
: If Not IsNull(IPConfig.IPAddress) Then
: For i = 0 to UBound(IPConfig.IPAddress)
: CurrentAddress=IpConfig.IPAddress(i)
: WScript.Echo "Checking lower boundry"
: select Case True
: case CurrentAddress >= "192.168.0.1 "
: WScript.Echo "Case 1 value of ok is " & ok
: WScript.Echo CurrentAddress
: range = "a"
: case CurrentAddress >= "170.150.0.1"
: range = "b"
: case CurrentAddress >= "10.150.0.1"
: range = "c"
: Case Else
: msg = "Failed lower boundry out of migration IP range."
: ok = False
: end Select
: WScript.Echo "Value of ok is: " & ok
: if ok Then
: WScript.Echo "Checking upper boundry"
: select case range
: Case "a"
: If CurrentAddress <= "192.168.255.254" Then migrate
: CurrentAddress
: WScript.Echo CurrentAddress
: case "b"
: if CurrentAddress <= "170.150.255.254" then migrate
: CurrentAddress
: case "c"
: if CurrentAddress <= "10.150.255.254" then migrate
: CurrentAddress
: case else
: msg = "out of migration IP range."
: end select
: end if
: Next
: End If
: Next
: End if
:
:
: prt msg
:
:
: Sub migrate(CurrentAddress)
: ' put migration code here
: prt "Migrating " & CurrentAddress & "..."
: End sub
:
:
: Sub prt(str)
: wscript.echo str
: End sub

I ran what you sent and I got this:

Initial value of ok is: True
Checking lower boundry
Case 1 value of ok is True
192.168.0.3
Value of ok is: True
Checking upper boundry
Migrating 192.168.0.3...
192.168.0.3
Migration process complete!

I'll see if I can make it fail but so far, it doesn't.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp




Re: getting client IP address ....... by Roland

Roland
Wed Nov 16 15:04:00 CST 2005

"Momo" <louey-3@excite.com> wrote in message
news:1131876562.743001.270680@z14g2000cwz.googlegroups.com...
: Attached here it is.......... all I did was copy the source you
: provided and added a few wscript.echo commands so that I could do some
: logging. I'm running the script with a worksation IP of 192.168.1.100.
: And its giving me an "Out of IP range" message........
:
: Thank you so much............
:
:
:
: Option Explicit
: Dim CurrentAddress, strComputer, objWMIService, IPConfigSet, IPConfig,
: i, msg, range, ok
: msg = "Migration process complete!"
: ok = True
: WScript.Echo "Initial value of ok is: " & ok
: strComputer = "."
:
:
: Set objWMIService =
: GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer
: & "\root\cimv2")
: Set IPConfigSet = objWMIService.ExecQuery ("SELECT * FROM
: Win32_NetworkAdapterConfiguration WHERE IPEnabled=true")
:
:
: If IPConfigSet.Count > 0 then
: For Each IPConfig in IPConfigSet
: If Not IsNull(IPConfig.IPAddress) Then
: For i = 0 to UBound(IPConfig.IPAddress)
: CurrentAddress=IpConfig.IPAddress(i)
: WScript.Echo "Checking lower boundry"
: select Case True
: case CurrentAddress >= "192.168.0.1 "
: WScript.Echo "Case 1 value of ok is " & ok
: WScript.Echo CurrentAddress
: range = "a"
: case CurrentAddress >= "170.150.0.1"
: range = "b"
: case CurrentAddress >= "10.150.0.1"
: range = "c"
: Case Else
: msg = "Failed lower boundry out of migration IP range."
: ok = False
: end Select
: WScript.Echo "Value of ok is: " & ok
: if ok Then
: WScript.Echo "Checking upper boundry"
: select case range
: Case "a"
: If CurrentAddress <= "192.168.255.254" Then migrate
: CurrentAddress
: WScript.Echo CurrentAddress
: case "b"
: if CurrentAddress <= "170.150.255.254" then migrate
: CurrentAddress
: case "c"
: if CurrentAddress <= "10.150.255.254" then migrate
: CurrentAddress
: case else
: msg = "out of migration IP range."
: end select
: end if
: Next
: End If
: Next
: End if
:
:
: prt msg
:
:
: Sub migrate(CurrentAddress)
: ' put migration code here
: prt "Migrating " & CurrentAddress & "..."
: End sub
:
:
: Sub prt(str)
: wscript.echo str
: End sub

I changed this line to test:
From: CurrentAddress=IpConfig.IPAddress(i)
To: CurrentAddress="192.168.1.100" 'IpConfig.IPAddress(i)

Result:
Initial value of ok is: True
Checking lower boundary
Case 1 value of ok is True
192.168.1.100
Value of ok is: True
Checking upper boundary
Migrating 192.168.1.100...
192.168.1.100
Migration process complete!

On a side note, I have a subroutine called prt so you don't have to keep
using wscript.echo. Just use prt in place of it.
Current code:

Option Explicit
Dim CurrentAddress, strComputer, objWMIService, IPConfigSet, IPConfig, i,
msg, range, ok
msg = "Migration process complete!"
ok = True
prt "Initial value of ok is: " & ok
strComputer = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery ("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled=true")

If IPConfigSet.Count > 0 then
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i = 0 to UBound(IPConfig.IPAddress)
CurrentAddress="192.168.1.100" 'IpConfig.IPAddress(i) ' *** this
line has been modified ***
prt "Checking lower boundary"
select Case True
case CurrentAddress >= "192.168.0.1 "
prt "Case 1 value of ok is " & ok
prt CurrentAddress
range = "a"
case CurrentAddress >= "170.150.0.1"
range = "b"
case CurrentAddress >= "10.150.0.1"
range = "c"
Case Else
msg = "Failed lower boundry out of migration IP range."
ok = False
end Select
prt "Value of ok is: " & ok
if ok Then
prt "Checking upper boundary"
select case range
Case "a"
If CurrentAddress <= "192.168.255.254" Then migrate
CurrentAddress
WScript.Echo CurrentAddress
case "b"
if CurrentAddress <= "170.150.255.254" then migrate
CurrentAddress
case "c"
if CurrentAddress <= "10.150.255.254" then migrate
CurrentAddress
case else
msg = "out of migration IP range."
end select
end if
Next
End If
Next
End if

prt msg

Sub migrate(CurrentAddress)
' put migration code here
prt "Migrating " & CurrentAddress & "..."
End sub

Sub prt(str)
wscript.echo str
End sub

I made the line I changed noticeable. Run it like this first and then run
it with the line changed back like it was.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: getting client IP address ....... by Momo

Momo
Thu Nov 17 04:34:01 CST 2005

Ok really appreciate it........... I'll have a look and see how it
goes...........

Once again thanks..........


Re: getting client IP address ....... by Momo

Momo
Thu Nov 17 10:53:34 CST 2005

Roland,

This is what I tried the test line with the IPaddress given in your
code 192.168.1.100 and it works fine, it checks the lower and upper
range and returns to start the migration process.

Then I tried it again using a different IPAddress for the test code
10.150.1.1 and again it works fine upper and lower range test ok and
starts migration.

However then I run it against the actual real machine removing the test
line. My machines IP is 192.169.1.100/24 and 192.168.1.1 gateway. As
soon as I run it against the machines actual IP it checks the "lower
boundary" and returns a for "OK as false. Hence ends the code......

Something seems very strange........ logically the code runs fine with
the test line, however when its run against the actual machines IP's it
returns false....... let me see if I can find out why.........

You mentioned that it ran fine when you tested it? Strange it doesn't
work on my machines (I actually tested it on 4 machines and all
failed).....


;-(


Re: getting client IP address ....... by Momo

Momo
Thu Nov 17 11:07:38 CST 2005

Roland,

This is what I tried the test line with the IPaddress given in your
code 192.168.1.100 and it works fine, it checks the lower and upper
range and returns to start the migration process.

Then I tried it again using a different IPAddress for the test code
10.150.1.1 and again it works fine upper and lower range test ok and
starts migration.

However then I run it against the actual real machine removing the test
line. My machines IP is 192.169.1.100/24 and 192.168.1.1 gateway. As
soon as I run it against the machines actual IP it checks the "lower
boundary" and returns a for "OK as false. Hence ends the code......

Something seems very strange........ logically the code runs fine with
the test line, however when its run against the actual machines IP's it
returns false....... let me see if I can find out why.........

You mentioned that it ran fine when you tested it? Strange it doesn't
work on my machines (I actually tested it on 4 machines and all
failed).....


;-(


Re: getting client IP address ....... by Roland

Roland
Sat Nov 19 10:25:45 CST 2005

"Momo" wrote in message
news:1132246414.920295.85740@g43g2000cwa.googlegroups.com...
: Roland,
:
: This is what I tried the test line with the IPaddress given in your
: code 192.168.1.100 and it works fine, it checks the lower and upper
: range and returns to start the migration process.
:
: Then I tried it again using a different IPAddress for the test code
: 10.150.1.1 and again it works fine upper and lower range test ok and
: starts migration.