由于网络设备的变化,我可能需要将一堆机器NIC设置回自动协商.什么是自动化的最佳方法?我在想通过组策略或SCCM推出一个Autoit编译的exe.如果您有示例,请发布您的脚本.我不确定我所打的所有系统都会有相同的NIC,所以将所有已知卡重置为auto的东西都会很棒.
谢谢!
-Mathew
这是一个执行您正在寻找的脚本.不过,你需要做一些“功课”才能让它发挥作用:
原文链接:https://www.f2er.com/windows/365923.htmlOption Explicit Const HIVE_HKLM = &H80000002 Const REG_DEVICE_PATH = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}" Const DEBUGGING = 1 Dim objRegistry,arrSubkeys,strSubkey,strComputer,regexpSubkey,strValue,dictDriverChanges,strDriverName Set dictDriverChanges = CreateObject("Scripting.Dictionary") ' For each given NIC,add an item for the driver description string (case insensitive match) and the value name and value that ' should be set in the NIC's properties Set dictDriverChanges.Item("Broadcom NetXtreme 57xx Gigabit Controller") = CreateObject("Scripting.Dictionary") dictDriverChanges.Item("Broadcom NetXtreme 57xx Gigabit Controller").Add "ValueName","*SpeedDuplex" dictDriverChanges.Item("Broadcom NetXtreme 57xx Gigabit Controller").Add "Value","0" ' Pattern to match on subkeys - exactly 4 digits Set regexpSubkey = new Regexp regexpSubkey.Global = True regexpSubkey.Pattern = "\d{4,4}" ' Comptuer to run against. Set to "." for the local computer,or specify the computer-name of a remote machine strComputer = "." Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") objRegistry.EnumKey HIVE_HKLM,REG_DEVICE_PATH,arrSubkeys ' Did we get back any strSubkeys? If IsArray(arrSubkeys) Then For Each strSubkey In arrSubkeys ' Is this a subkey we want to look at If regexpSubkey.Execute(strSubkey).Count = 1 Then objRegistry.GetStringValue HIVE_HKLM,REG_DEVICE_PATH & "\" & strSubkey,"DriverDesc",strValue ' Loop through all the drivers we know about looking for this driver For Each strDriverName in dictDriverChanges If UCase(strDriverName) = UCase(strValue) Then If DEBUGGING = 1 Then WScript.Echo "Located driver " & strValue & ". Setting value " & dictDriverChanges.Item(strDriverName).Item("ValueName") & " to " & dictDriverChanges.Item(strDriverName).Item("Value") objRegistry.SetStringValue HIVE_HKLM,dictDriverChanges.Item(strDriverName).Item("ValueName"),dictDriverChanges.Item(strDriverName).Item("Value") End If Next ' strDriverName End If Next ' strSubkey End If
您需要找到您想要更改的每种NIC的“DriverDesc”值. (在每个子键的REG_DEVICE_PATH下的注册表中查找各种DriverDesc值).我在脚本中包含了Broadcom 57xx控制器的说明.您需要为每种NIC识别注册表值名称和值设置,然后为每种NIC添加类似于第11-15行的条目.
这对目前的本地计算机运行.让它在命令行上获取计算机名称并对远程计算机运行并不会太难.或者,您可以在每台计算机上本地运行它.
在脚本运行后,您需要重新启动计算机才能使更改生效.如果您在Windows Vista或Windows 7上运行此功能,请注意它必须在“高架”上下文中运行. (它是在Windows 7上开发的,在Windows XP上运行良好……)
这应该会解决你的问题.