Цитата: кто подскажет, как определить режим работы сетевой карты параметры speed и duplex
WSQ2 Дело в том что различные адаптеры этот параметр определяют по разному. Т.е. непроходимо адаптировать под свои условия.
для примера:
Код: Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
' This is the base registry key for NICs
strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\00"
strValueName = "DriverDesc"
'Set up a couter for at least 30 different entries in the key
for strcount=0 to 30
if strcount<10 then
strcount="0"&strcount
end if
'Read the value of the nic description
oReg.GetstringValue HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
'objfile.WriteLine "Device description: " & strValue
'compare to identified string values and set value accordingly.
if instr(strvalue,"Intel")> 0 And InStr(strValue,"Wireless")<=0 then
strValueName = "SpeedDuplex"
'oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strNICSpeed
WScript.Echo strNICSpeed
Select Case strSpeed
Case 0:
WScript.Echo "Intel NIC with Auto Detect settings"
Case 1:
WScript.Echo "Intel NIC with 10Mbps/Half Duplex settings"
Case 2:
WScript.Echo "Intel NIC with 10Mbps/Full Duplex settings"
Case 3:
WScript.Echo "Intel NIC with 100Mbps/Half Duplex settings"
Case 4:
WScript.Echo "Intel NIC with 100Mbps/Full Duplex settings"
Case 5:
WScript.Echo "Intel NIC with Auto Negotiate 1000Mbps settings"
Case Else
WScript.Echo "Intel NIC with Unknown Setting"
End Select
end If
'You might need to change the below as per the above select cases.
if instr(strvalue,"Broadcom") then
strValueName = "RequestedMediaType"
''strvalue="0" 'set auto
strValue = "6" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "3Com EtherLink XL 10/100 PCI TX NIC (3C905B-TX)" then
strValueName = "Duplexmode"
''strvalue="Hardware Default" 'set auto
strValue = "Full Duplex" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
strValueName = "MediaSelect"
''strvalue="Auto Select" 'set auto
strValue = "100BaseTx" 'set full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "3Com EtherLink 10/100 PCI For Complete PC Management NIC (3C905C-TX)" then
strValueName = "media_type"
''strvalue="Autoselect" 'set auto
strValue = "100FULL" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "3Com EtherLink XL 10/100 PCI For Complete PC Management NIC (3C905C-TX)" then
strValueName = "Duplexmode"
''strvalue="Hardware Default" 'set auto
strValue = "Full Duplex" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
strValueName = "MediaSelect"
''strvalue="Auto Select" 'set auto
strValue = "100BaseTx" 'set full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "3Com 3C918 Integrated Fast Ethernet Controller (3C905B-TX Compatible)" then
strValueName = "Duplexmode"
''strvalue="Hardware Default" 'set auto
strValue = "Full Duplex" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
strValueName = "MediaSelect"
''strvalue="Auto Select" 'set auto
strValue = "100BaseTx" 'set full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "Accton EN1207D-TX PCI Fast Ethernet Adapter" then
strValueName = "DuplexMode"
''strvalue="1" 'set auto
strValue = "5" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "Accton EN1207F Series PCI Fast Ethernet Adapter" then
strValueName = "MediaType"
''strvalue="0" 'set auto
strValue = "4" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "Compaq NC3123 Fast Ethernet NIC" then
strValueName = "SpeedDuplex"
''strvalue="0" 'set auto
strValue = "4" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if instr(strvalue,"FE57") then
strValueName = "LinkSelection"
''strvalue="0200" 'set auto
strValue = "0100" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if instr(strvalue,"Realtek RTL8139") then
strValueName = "Duplex Mode"
''strvalue="1" 'set auto
strValue = "5" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "Realtek RTL8139/810x Family Fast Ethernet NIC" then
strValueName = "Duplex Mode"
''strvalue="1" 'set auto
strValue = "5" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if instr(strvalue,"VIA") then
strValueName = "ConnectionType"
''strvalue="0" 'set auto
strValue = "2" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
if strvalue = "Xircom Ethernet Adapter 10/100" then
strValueName = "LineMode"
''strvalue="0" 'set auto
strValue = "2" 'set 100 full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
strValueName = "LineSpeed"
''strvalue="0" 'set auto
strValue = "2" 'set full
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath&strcount,strValueName,strValue
end if
next