468,483 Members | 2,646 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,483 developers. It's quick & easy.

Windows Script Host Type mismatch 800A000D error

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?

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim IP_Address : IP_Address = GetIP()
  3. IP_Address = ip2num(IP_Address)
  4.  
  5. If IP_Address = "0.0.0.0" OR IP_Address = "" Then
  6.   MsgBox "No IP Address found  Unable to configure."
  7. Else
  8.       Dim WshNetwork
  9.       Dim objShell
  10.       Set WshNetwork = CreateObject("WScript.Network")
  11.       Set objShell = CreateObject("Wscript.Shell")
  12.   If IP_Address >= ip2num("10.100.10.1") _
  13.     And IP_Address <= ip2num("10.100.10.79") Then
  14.     Set objShell = WScript.CreateObject("WScript.Shell")
  15.     objShell.Run("%comspec% /K C:\Scripts\Machine\d.bat"), 1, True
  16.   ElseIf IP_Address >= ip2num("10.100.10.80") _
  17.     And IP_Address <= ip2num("10.100.10.89") Then
  18.     Set objShell = WScript.CreateObject("WScript.Shell")
  19.     objShell.Run("%comspec% /K C:\Scripts\Machine\baseConfig.bat"), 1, True
  20.   ElseIf IP_Address >= ip2num("10.100.10.90") _
  21.     And IP_Address <= ip2num("10.100.10.254") Then
  22.     Set objShell = WScript.CreateObject("WScript.Shell")
  23.     objShell.Run("%comspec% /K C:\Scripts\Machine\d.bat"), 1, True
  24.   ElseIf IP_Address >= ip2num("10.100.20.1") _
  25.     And IP_Address <= ip2num("10.100.20.254") Then
  26.     Set objShell = WScript.CreateObject("WScript.Shell")
  27.     objShell.Run("%comspec% /K C:\Scripts\Machine\h.bat"), 1, True
  28.   ElseIf IP_Address >= ip2num("10.100.30.1") _
  29.     And IP_Address <= ip2num("10.100.30.254") Then
  30.     Set objShell = WScript.CreateObject("WScript.Shell")
  31.     objShell.Run("%comspec% /K C:\Scripts\Machine\sunset.bat"), 1, True
  32.   ElseIf IP_Address >= ip2num("10.100.40.1") _
  33.     And IP_Address <= ip2num("10.100.40.254") Then
  34.     Set objShell = WScript.CreateObject("WScript.Shell")
  35.     objShell.Run("%comspec% /K C:\Scripts\Machine\b.bat"), 1, True
  36.   ElseIf IP_Address >= ip2num("10.100.60.1") _
  37.     And IP_Address <= ip2num("10.100.60.254") Then
  38.     Set objShell = WScript.CreateObject("WScript.Shell")
  39.     objShell.Run("%comspec% /K C:\Scripts\Machine\t.bat"), 1, True
  40.   ElseIf IP_Address >= ip2num("10.100.70.1") _
  41.     And IP_Address <= ip2num("10.100.70.254") Then
  42.     Set objShell = WScript.CreateObject("WScript.Shell")
  43.     objShell.Run("%comspec% /K C:\Scripts\s.bat"), 1, True
  44.   End If
  45. End If
  46.  
  47. Function GetIP()
  48.   Dim ws : Set ws = CreateObject("WScript.Shell")
  49.   Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
  50.   Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
  51.   Dim ThisLine, IP
  52.   If ws.Environment("SYSTEM")("OS") = "" Then
  53.     ws.run "winipcfg /batch " & TmpFile, 0, True
  54.   Else
  55.     ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
  56.   End If
  57.   With fso.GetFile(TmpFile).OpenAsTextStream
  58.     Do While NOT .AtEndOfStream
  59.       ThisLine = .ReadLine
  60.       If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
  61.     Loop
  62.     .Close
  63.   End With
  64.   'WinXP (NT? 2K?) leaves a carriage return at the end of line
  65.   If IP <> "" Then
  66.     If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
  67.   End If
  68.   GetIP = IP
  69.   fso.GetFile(TmpFile).Delete 
  70.   Set fso = Nothing
  71.   Set ws = Nothing
  72. End Function
  73.  
  74. Public Function ip2num(ip)
  75.     Dim i, a, N
  76.     a = Split(IP, ".")
  77.     N = CDbl(0)
  78.     For i = 0 To UBound(a)
  79.       N = N * 256 + a(i)
  80.     Next
  81.     ip2num = N
  82. End Function
  83.  
Aug 25 '10 #1
1 4052
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.
Aug 30 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by amitbadgi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.