|
改好了
- Set WshShell = CreateObject("WScript.Shell")
- Const HKLM = &H80000002
- strActivenet ="本地连接," ''设置要保留的网络设备名称,每个网络设备后面要加小写逗号",",即使只有1个要保留的也要加
- Dim strPath(2)
- strPath(0) = "CurrentControlSet"
- strPath(1) = "ControlSet001"
- strPath(2) = "ControlSet002"
- Set oReg = GetObject("Winmgmts:\root\default:StdRegProv")
- For i = 0 To uBound(strPath)
- strPathA="SYSTEM" & strPath(i) & "\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}"
- oReg.EnumKey HKLM,strPathA,entries
- On Error Resume Next
- For Each subkey In entries
- strPathA1 = strPathA & "" & subkey
- strPathA2 = strPathA1 & "\Connection"
- oReg.GetStringValue HKLM,strPathA2,"Name",strName
- If IsNull(strName) = False Then
- 'oReg.GetStringValue HKLM,strPathA2,"Name",strName
- If InStr(1,strActivenet,strName & ",",1) = 0 Then
- oReg.GetStringValue HKLM,strPathA2,"PnpInstanceID",strValue
- If IsNull(strValue) = False Then
- strPathB = "HKLM\SYSTEM" & strPath(i) & "\Enum" & strValue
- 'WshShell.PopUp "找到网络连接: " & strName & vbCrLf & "设备位置:" & strPathB ''本行为测试,如需测试,把本行最前的单引号删掉,把两行WshShell.Run用单引号注释,则不会产生操作,只显示找到的数据
- WshShell.Run "reg delete " & strPathB & " /f",0 '删除网络设备的硬件信息
- Else
- 'WshShell.PopUp "找到网络连接: " & strName & vbCrLf & "此设备没有硬件信息,应该是被微软清除之后残留,作用未知,建议备份注册表之后再删除" '''本行也是测试
- End If
- WshShell.Run "reg delete HKLM" & strPathA1 & " /f",0 '删除显示的网络设备
- End If
- End If
- Next
- Next
复制代码
那三个ControlSet其实只需要处理CurrentControlSet就可以了,001会在关机的时候被CurrentControlSet覆盖,002是启动菜单的那个最后一次正确配置,在“正确”启动之后被001覆盖,微软的用户登录了就算正确启动了 。 |
|