I have made a script where, if a user falls within a defined IP range, a batch file will run.
The problem I'm having is that if a user has both a LAN and WIFI connection in the same range, the batch file will run twice.
Any idea how I can make the batch file run only once? I've tried using counters but I kept getting errors and can not figure it out.
Thanks alot in advance !
Please see the Code Box for the entire code.
If Ip > "194.7.23.199" And Ip < "194.7.23.255" Or Ip > "192.168.180.99" And Ip < "192.168.180.200" Or Ip > "192.168.181.99" And Ip < "192.168.181.200" and InStr(sysInfo.ComputerName, "OU=" & SBX) > 0 Then
shell.run("\\SERVER\NETLOGON\Other\pstbackup\Check.bat")
Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")
Dim Ip, Z1, Z2, i
Dim shell, counter
set shell=createobject("wscript.shell")
Set sysInfo = CreateObject("ADSystemInfo")
For Each Obj in Wmi.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=1",,48)
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
If Ip > "194.7.23.199" And Ip < "194.7.23.255" Or Ip > "192.168.180.99" And Ip < "192.168.180.200" Or Ip >
"192.168.181.99" And Ip < "192.168.181.200" and InStr(sysInfo.ComputerName, "OU=" & SBX) > 0 Then
shell.run("\\SERVER\NETLOGON\Other\pstbackup\Check.bat")
Elseif Ip > "192.168.199.109" And Ip < "192.168.199.161" and InStr(sysInfo.ComputerName, "OU=" & SB) > 0 Then
shell.run("\\SERVER\NETLOGON\Other\pstbackup\Check.bat")
End If
Next
set shell=nothing
WScript.Quit



Help
Back to top









