Hi all,
I have used the following code in the past under Windows Xp without issue to run a series of configuration files based on the IP range. However, I get the above error message on Line 79 Char 7 (the Split command) under Windows 7 64-bit. I'm stumped, any ideas? -
Option Explicit
-
Dim IP_Address : IP_Address = GetIP()
-
IP_Address = ip2num(IP_Address)
-
-
If IP_Address = "0.0.0.0" OR IP_Address = "" Then
-
MsgBox "No IP Address found – Unable to configure."
-
Else
-
Dim WshNetwork
-
Dim objShell
-
Set WshNetwork = CreateObject("WScript.Network")
-
Set objShell = CreateObject("Wscript.Shell")
-
If IP_Address >= ip2num("10.100.10.1") _
-
And IP_Address <= ip2num("10.100.10.79") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\Machine\d.bat"), 1, True
-
ElseIf IP_Address >= ip2num("10.100.10.80") _
-
And IP_Address <= ip2num("10.100.10.89") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\Machine\baseConfig.bat"), 1, True
-
ElseIf IP_Address >= ip2num("10.100.10.90") _
-
And IP_Address <= ip2num("10.100.10.254") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\Machine\d.bat"), 1, True
-
ElseIf IP_Address >= ip2num("10.100.20.1") _
-
And IP_Address <= ip2num("10.100.20.254") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\Machine\h.bat"), 1, True
-
ElseIf IP_Address >= ip2num("10.100.30.1") _
-
And IP_Address <= ip2num("10.100.30.254") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\Machine\sunset.bat"), 1, True
-
ElseIf IP_Address >= ip2num("10.100.40.1") _
-
And IP_Address <= ip2num("10.100.40.254") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\Machine\b.bat"), 1, True
-
ElseIf IP_Address >= ip2num("10.100.60.1") _
-
And IP_Address <= ip2num("10.100.60.254") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\Machine\t.bat"), 1, True
-
ElseIf IP_Address >= ip2num("10.100.70.1") _
-
And IP_Address <= ip2num("10.100.70.254") Then
-
Set objShell = WScript.CreateObject("WScript.Shell")
-
objShell.Run("%comspec% /K C:\Scripts\s.bat"), 1, True
-
End If
-
End If
-
-
Function GetIP()
-
Dim ws : Set ws = CreateObject("WScript.Shell")
-
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
-
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
-
Dim ThisLine, IP
-
If ws.Environment("SYSTEM")("OS") = "" Then
-
ws.run "winipcfg /batch " & TmpFile, 0, True
-
Else
-
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
-
End If
-
With fso.GetFile(TmpFile).OpenAsTextStream
-
Do While NOT .AtEndOfStream
-
ThisLine = .ReadLine
-
If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
-
Loop
-
.Close
-
End With
-
'WinXP (NT? 2K?) leaves a carriage return at the end of line
-
If IP <> "" Then
-
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
-
End If
-
GetIP = IP
-
fso.GetFile(TmpFile).Delete
-
Set fso = Nothing
-
Set ws = Nothing
-
End Function
-
-
Public Function ip2num(ip)
-
Dim i, a, N
-
a = Split(IP, ".")
-
N = CDbl(0)
-
For i = 0 To UBound(a)
-
N = N * 256 + a(i)
-
Next
-
ip2num = N
-
End Function
-
1 4392
Turns out this error was caused by ipv6. The script was correct, but the format of the IP on a different adapter had changed. Disabling Teredo and ISATAP adapters fixed it.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: amitbadgi |
last post by:
I am getting teh following error while converting an asp application to
asp.net,
Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch.
Source Error:
Line...
|
by: Stealth3si |
last post by:
I hope this is the right thread /forum to place this topic in.
I'm trying to execute a .vbs file (double-click) on Windows 2000 Advanced Server with Service Pack 4 (on administrator account) and...
|
by: Osoccer |
last post by:
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem:
I need a...
|
by: ApexData |
last post by:
Access2k
I WAS getting the following error when using the MID function:
Run Time Error '13' Type Mismatch
I have a new single form, unbound with 1-button on it that uses the
following code:...
|
by: NarutoFanatic |
last post by:
Hi,
Im currently updating our email sending functionality of our application. The website is written in classic asp and all codes are really a mess. anyway my problem is that our current process...
| |
by: dstorms |
last post by:
Hi,
I'm trying to create a button on a form that:
1. Takes the ComputerID from the form linked to Table 1,
2. Checks Table 2 for a matching ComputerID, and
3. Opens the query qryEditData, and...
|
by: FishVal |
last post by:
Windows Script Host Object library.
Full name: Windows Script Host Object Model
LibName: IWshRuntimeScripting
Location: ...\WINDOWS\system32\wshom.ocx
The present tip is closely related to...
|
by: DonRayner |
last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm...
|
by: kmeistrmuffinmang |
last post by:
Hi am new to script with WSH. Can anybody help fin out how to connect to a PostgreSQL database using WSH?
Thank you,
Kmeistrmuffinmang
|
by: shalskedar |
last post by:
For r = 2 To 28
Do While Len(Range("A" & r).Formula) > 0
rs.AddNew
rs.Fields(0) = Range("A" & r).Value
rs.Fields(1) = Range("C" & r).Value
'Debug.Print r & ":(" & Range("D" & r).Value & ")"...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |