1

我需要检查是否在服务器上禁用了 IPv6。我的脚本无法启用或禁用它,只需检查一下。

我在不久前发表了这篇文章,VBScript 子例程检查注册表中的 IPv6 状态...返回 -1,我一直在使用这个逻辑,它一直运行良好。今天我遇到了一个问题,我得到了一个假阴性。适配器上的 IPv6 复选框未选中,我的代码逻辑(在我粘贴的链接中)没有检查,“DisabledComponents”键甚至不存在。

我已经搜索了几个小时,但找不到任何知道默认网络适配器是否启用 IPv6 的方法。我会很好地遍历所有网络适配器,但 WMI 网络适配器中没有一个属性可以告诉我是否启用了 IPv6。

不幸的是,我不知所措...

有什么建议么?

PS我的代码在链接中

编辑:Rene 解决方案的输出

    SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\ no disabled components

    \Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD}  = \Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD}
    \Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961}  = \Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961}
    \Device\{F2E73C76-C023-492D-8A14-824233F953F9}  = \Device\{F2E73C76-C023-492D-8A14-824233F953F9}
    \Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2}  = \Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2}
    \Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2}  = \Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2}
    \Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7}  = \Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7}
    \Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0}  = \Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0}
    \Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50}  = \Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50}
\Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{5EB82563-B53C-487C-9071-2FFEEF3ACFFD}
\Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{C22E58F2-C979-4CAE-8B15-73DFE86E8961}
\Device\{F2E73C76-C023-492D-8A14-824233F953F9} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{F2E73C76-C023-492D-8A14-824233F953F9}
\Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{7D754194-9C49-44C4-9D39-5C5CE1A79EE2}
\Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{07F7960F-D1A0-408C-8BDB-88FE296F0BB2}
\Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{8D600902-D19B-462B-995B-C79EDB9BD9C7}
\Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{5E848319-EF8D-46F2-863E-A11BA9033FB0}
\Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{98EC2BBC-2FC1-4FD7-A925-7DE3F17ECC50}
\Device\{9E85E61A-EBB4-40E0-BB55-31FE48973DD2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{9E85E61A-EBB4-40E0-BB55-31FE48973DD2}
\Device\{4E0B9F15-E1C9-4093-A929-419BE1B089FB} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{4E0B9F15-E1C9-4093-A929-419BE1B089FB}
\Device\{4974F3E4-7493-428A-8DD4-3A43F64ACA00} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{4974F3E4-7493-428A-8DD4-3A43F64ACA00}
\Device\{C6E0B4F3-BC2C-49D7-9178-41F6F9C75C94} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{C6E0B4F3-BC2C-49D7-9178-41F6F9C75C94}
\Device\{8BE42170-83DC-4A40-880A-3163A88D8540} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{8BE42170-83DC-4A40-880A-3163A88D8540}
\Device\{8EBA3452-69B1-4284-A859-58B9C3A2735B} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{8EBA3452-69B1-4284-A859-58B9C3A2735B}
\Device\{046E21CF-38BB-447B-81F1-12536E4260DE} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{046E21CF-38BB-447B-81F1-12536E4260DE}
\Device\{FB30DEEC-3A32-47FF-A8CC-EBFB112D29C2} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{FB30DEEC-3A32-47FF-A8CC-EBFB112D29C2}
\Device\{72A0EBC4-11EE-4A57-8F4E-9771264B7C74} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{72A0EBC4-11EE-4A57-8F4E-9771264B7C74}
\Device\{767698C6-D554-4EFF-8D15-9F2F6BDA5FD3} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{767698C6-D554-4EFF-8D15-9F2F6BDA5FD3}
\Device\{CE60A593-435C-40C3-8D2D-F48D00F743B6} {5E848319-EF8D-46F2-863E-A11BA9033FB0} = {5E848319-EF8D-46F2-863E-A11BA9033FB0}\Device\{CE60A593-435C-40C3-8D2D-F48D00F743B6}
    ...

它包括更多,但我只粘贴了一个片段。

4

1 回答 1

1

从此处改编脚本并使用此 kb 文章作为源。该脚本枚举值以首先检查是否找到 DisabledComponents,它是它的回显它的内容。如果从未找到它,则回显没有找到任何值(这基本上意味着:全部启用)

'**************************************************************************
'IP Address Configuration: Check if ipv6 is disabled
'**************************************************************************
Sub CheckIPV6()
   WScript.Echo("Check if IPv6 is disabled")
   WScript.Echo("------------------------------------")
   Const strIPV6Key = "SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\"
   strValueName = "DisabledComponents"
   Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
   objRegistry.EnumValues HKEY_LOCAL_MACHINE, strIPV6Key, arrValueNames, arrTypes
   IPv6Disabled = false
   For I=0 To UBound(arrValueNames)
      IF arrValuesNames(I) = strValueName THEN
         objRegistry.GetDWORDValue HKEY_LOCAL_MACHINE, strIPV6Key,strValueName,strIPV6Status
         WScript.Echo(strIPV6Key & strValueName & " = " & strIPV6Status & vbCrLf)
         IPv6Disabled = true
      END IF
   NEXT
   IF NOT IPv6Disabled THEN
          WScript.Echo(strIPV6Key & " no disabled components" & vbCrLf)
   END IF

   Set objWMIService = GetObject(_
          "winmgmts:\\" & strComputer & "\root\cimv2")
   Set colNics = objWMIService.ExecQuery _
           ("Select * From Win32_NetworkAdapter ")


    objRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE, _
          "SYSTEM\CurrentControlSet\services\Tcpip6\Linkage", _
          "Bind",bindValues

   For Each objNic in colNics
        For Each strValue In bindValues
          REM DEBUG to see what values are read
          WScript.echo strValue & " " & objNic.GUID & " = " & Cstr( objNic.GUID = strValue)
        Next
   Next

End Sub

WIN32_NetworkAdapter 通过 wmi
多字符串注册表读取

于 2013-03-11T19:53:49.060 回答