RenameTap.vbs Script error

Hi,

I have just installed eCatcher and got the error “VPN Tunnel error: TAP-Windows adapter ‘talk2M-eCatcher’ not found”. I first ran the “AddTap.bat” followed by RenameTap.Vbs.

the .Bat file created the adapter but when i run the .vbs file i got a script error:

image

Is there anyone else that has encoutered this issue?

' Enum network services
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")

Dim WshShell, RegValue
Set WshShell = WScript.CreateObject("WScript.Shell")

Dim CurrentConnectionName
NewConnectionName = "Talk2m-eCatcher"
LegacyConnectionName = "Talk2m-eCatcher Connection"
QuickConnect = "QuickConnect" 'used to prevent renaming of Quickconnect TAP interface
NamedConnectionFound = False  ' Do we already have a Talk2m-eCatcher TAP interface?
LegacyConnectionFound = False ' Do we have a Talk2m-eCatcher Connection TAP interface? (that name was used in eCatcher<6.3)
Retries = 0

' Enum NICs. Look for the TAP.
Do 
    For Each objItem in colItems
        if InStr(objItem.ServiceName, "tap0901")>0 OR InStr(objItem.Caption, "TAP-Win32 Adapter V9")>0 OR InStr(objItem.Caption, "TAP-Windows Adapter V9")>0 then
            Wscript.Echo "This is a TAP NIC"

            Wscript.Echo "Caption = " & objItem.Caption
            Wscript.Echo "ServiceName = " & objItem.ServiceName

            ' this is a TAP NIC -> lookup its current name
            ThisConnectionName = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & objItem.SettingID & "\Connection\Name")
            Wscript.Echo "ConnectionName = " & ThisConnectionName

            if InStr(1, ThisConnectionName, QuickConnect) = 0 and IsEmpty(CurrentConnectionName) then
                CurrentConnectionName = ThisConnectionName
                end if
    
            if ThisConnectionName = NewConnectionName then 
                NamedConnectionFound = True
                end if

            if ThisConnectionName = LegacyConnectionName then 
                LegacyConnectionFound = True
                CurrentConnectionName = ThisConnectionName ' We'll use this TAP interface in priority (it is one already installed by a former eCatcher installation, but we need to rename it)
                end if

            end if
        Next        

    Retries = Retries + 1
    if IsEmpty(CurrentConnectionName) Then
        WScript.Echo "No TAP interface found. Wait a bit, it might still be initializing..."
        WScript.Sleep 1000
        End If

Loop While IsEmpty(CurrentConnectionName) and (Retries < 5)

' Rename interface
If NamedConnectionFound Then
    Wscript.Echo "There is already a tap interface named " & chr(34) & NewConnectionName & chr(34)
ElseIf IsEmpty(CurrentConnectionName) Then
    Wscript.Echo "No TAP interface found"
Else
    Wscript.Echo "Renaming connection " & CurrentConnectionName & " to " & NewConnectionName & "..."
    if LegacyConnectionFound then
        Wscript.Echo "(re-using TAP interface installed by older version of eCatcher)"
        end if
    
    strCmd= WshShell.ExpandEnvironmentStrings("%WinDir%") & "\system32\netsh interface set interface name=" & chr(34) & CurrentConnectionName & chr(34) & " newname=" & chr(34) & NewConnectionName & chr(34)
    'Wscript.Echo strCmd

    Set oExec = WshShell.Exec(strCmd)

    Do While oExec.Status = 0
        WScript.Sleep 100
    Loop
    Wscript.Echo "Interface renamed."
End If

Seems like something at this row: For Each objItem in colItems but i do not get why…

Hi @JohanN,

You can just rename the TAP Adapter manually if the script doesn’t work for you. The script works on my PC, so I think this is something localized to your PC.

image