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