none
VBScript to enable "Use this connection's DNS Suffix in DNS registration" in IPV4 RRS feed

  • Question

  • HI
    I have found this script on a blog and it's working just fine.
    This VBScript is enabling "Use this connection's DNS Suffix in DNS registration" in IPV4 Advanced Settings and it's doing it for every network interfaces. 
    But How do I change the script so it only change all interfaces with a REG_SZ key called "Domain REG_SZ = vpn.domain.com"
    This key is placed under:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{INTERFACE......}]

    After you have located the right interface then it should change the key "RegisterAdapterName" to 1.

    On Error Resume Next

    Dim
    NetworkInterfaceID, RegKeyValue, Temp

    'HKEY_CURRENT_USER = HKCU

     'HKEY_LOCAL_MACHINE = HKLM

     'HKEY_CLASSES_ROOT = HKCR

     'HKEY_USERS = HKEY_USERS

     'HKEY_CURRENT_CONFIG = HKEY_CURRENT_CONFIG

    Function KeyExists(key)

        Dim objShell

        On Error Resume Next

        Set objShell = CreateObject("WScript.Shell") 
    objShell.RegRead (key)

        Set objShell = Nothing

        If Err = 0 Then KeyExists = True

    End Function

    For i = 0 to 20

      

    RegistryKeyName
    = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\" & i & "\"

    If
    KeyExists(RegistryKeyName) Then

    Reg= RegistryKeyName + "ServiceName"

    NetworkInterfaceID = ReadReg(Reg)

    RegKeyValue = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\"
    + NetworkInterfaceID + "\RegisterAdapterName"

    WriteReg RegKeyValue, 1 ,"REG_DWORD"

    End If

    Next

     'WScript.Echo Temp

     Function WriteReg(RegPath, Value, RegType)

      'Regtype should be "REG_SZ" for string, "REG_DWORD" for a integer,…

       '"REG_BINARY" for a binary or boolean, and "REG_EXPAND_SZ" for an expandable string

          Dim objRegistry, Key

           Set objRegistry = CreateObject("Wscript.shell")

          Key = objRegistry.RegWrite(RegPath, Value, RegType)

          WriteReg = Key

     End Function

     Function ReadReg(RegPath)

      Dim objRegistry, Key 
    Set objRegistry = CreateObject("Wscript.shell")

         
    Key = objRegistry.RegRead(RegPath)
    ReadReg = Key

     End Function


    Thanks for your help.

    Regards
    MHEM




    • Edited by MHem Friday, November 14, 2014 1:02 PM
    Friday, November 14, 2014 12:48 PM

Answers