Hello,
I'm trying to set up a script to have the ip range checked on clients.
If they fall into a certain range, the script must execute some batch file.
This is working as long as the client only has one network card installed.
For example, it works perfectly on my own workstation but as soon as I had a loopback adapter for example, it no longer works.
In other words, it only seems to look at first interface it can find.
Any idea what I need to change or add to make the script look at all available network interfaces?
Thank you in advance.
Here's the afformentioned script.
Note I do not have that much scripting experience and kind of hacked this together from parts of other scripts I could find.
Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")
Dim Ip, Z1, Z2
Dim shell
set shell=createobject("wscript.shell")
For Each Obj in Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")
If not isNull(Obj.IPSubnet) Then
If not isNull(Obj.IPAddress) Then
Z1 = Join(Obj.IPAddress, ",")
If Len(Z1) <= 15 Then
Ip = Z1
ElseIf Len(Z1) >= 16 Then
Z2 = Split(Z1, ",")
Ip = Z2(0)
End If
End If
End If
Next
If Ip > "194.7.23.200" And Ip < "194.7.23.254" Then
shell.run "RUN BATCH1"
ElseIf Ip > "192.168.180.100" And Ip < "192.168.180.199" Then
shell.run "RUN BATCH2"
ElseIf Ip > "192.168.180.100" And Ip < "192.168.180.199" Then
shell.run "RUN BATCH3"
End If
set shell=nothing
WScript.Quit
I'm trying to set up a script to have the ip range checked on clients.
If they fall into a certain range, the script must execute some batch file.
This is working as long as the client only has one network card installed.
For example, it works perfectly on my own workstation but as soon as I had a loopback adapter for example, it no longer works.
In other words, it only seems to look at first interface it can find.
Any idea what I need to change or add to make the script look at all available network interfaces?
Thank you in advance.
Here's the afformentioned script.
Note I do not have that much scripting experience and kind of hacked this together from parts of other scripts I could find.
Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")
Dim Ip, Z1, Z2
Dim shell
set shell=createobject("wscript.shell")
For Each Obj in Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")
If not isNull(Obj.IPSubnet) Then
If not isNull(Obj.IPAddress) Then
Z1 = Join(Obj.IPAddress, ",")
If Len(Z1) <= 15 Then
Ip = Z1
ElseIf Len(Z1) >= 16 Then
Z2 = Split(Z1, ",")
Ip = Z2(0)
End If
End If
End If
Next
If Ip > "194.7.23.200" And Ip < "194.7.23.254" Then
shell.run "RUN BATCH1"
ElseIf Ip > "192.168.180.100" And Ip < "192.168.180.199" Then
shell.run "RUN BATCH2"
ElseIf Ip > "192.168.180.100" And Ip < "192.168.180.199" Then
shell.run "RUN BATCH3"
End If
set shell=nothing
WScript.Quit