Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with reading the correct subkey's

Status
Not open for further replies.

Bachatero

Programmer
Aug 30, 2006
36
NL
Hi All,

I use the following command to read the contens of the field: driverdiscription:

For Each subkey In arrSubKeys

My script returns two subkeys 0000 and 0001

But if I use regedit I can see that there are 9 subkeys. The subkeys 0000 - 0008.

My first nic has the key 0001 and my second nic has the subkey 0002.

Because my script reads only two subkeys in this case key 0000 and 0001 I am not able to read my second nic.

Any idea how to solve this?

Thanks in advance,

Johan

Code:
Sub ZoekNetwerkKaarten(strComputer)
    Dim objReg
    Dim blnNicFound
    Dim strKeyPath,arrSubKeys,subkey,strValue
    On Error Resume Next
    blnNicFound = True
    Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
    If Err Then 
        WScript.Echo("Fout tijdens het lezen van het register op: " & strComputer)
        Exit Sub
    Else		
        strKeyPath = "System\Currentcontrolset\Control\Class\{4D36E972-E325-11CE-BFC1-08002be10318}"
        objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys	

		logfile.WriteLine(VisueleKaderlijnNetwerkSpeedInfo + vbNewLine)		
		
        For Each subkey In arrSubKeys		  
		
            
            objReg.GetStringvalue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subkey,"DriverDesc", strValue	
			DebugMessage("SubKey: "   & subkey)
			DebugMessage("strValue: " & strValue)
			

			
            Select Case strValue
                Case "3Com EtherLink XL 10/100 PCI TX NIC (3C905B-TX)"
                    WScript.Echo "** Controleer de netwerk instelling handmatig! **"
                    Exit Sub
					
				Case "SysKonnect SK-9521 V2.0 10/100/1000Base-T Adapter, PCI, Copper RJ-45"
				
                    NetwerkSnelheid = LeesVerbindingsSnelheid (strKeyPath & "\" & subkey, "ConnectionType_A", strComputer, strValue)
					
					If NetwerkSnelheid = "" Then
						NetwerkSnelheid = LeesVerbindingsSnelheid (strKeyPath & "\" & subkey, "*SpeedDuplex", strComputer, strValue)
					End If
					
					If NetwerkSnelheid = "0" Then 
							DuplexSnelheid = "Auto Detect"
						End If
					 
						If NetwerkSnelheid = "1" Then 
							DuplexSnelheid = "10 Mbps/Half Duplex"
						End If
					 
						If NetwerkSnelheid = "2" Then 
							DuplexSnelheid = "10 Mbps/Full Duplex"
						End If
					 
						If NetwerkSnelheid = "3" Then 
							DuplexSnelheid = "100 Mbps/Half Duplex"
						End If					 
					 
						If NetwerkSnelheid = "4" Then 
							DuplexSnelheid = "100 Mbps/Full Duplex"
						End If	

						If NetwerkSnelheid = "5" Then 
							DuplexSnelheid = "Auto-negotiate 1000Mbps"
						End If	

						logfile.WriteLine "  Netwerk snelheid voor SysKonnect SK-9521 V2.0 10/100/1000Base-T Adapter, PCI, Copper RJ-45 staat ingesteld op: " & DuplexSnelheid
					
                    Exit Sub					
					
                Case "Broadcom NetXtreme Gigabit Ethernet", _
					 "Broadcom NetXtreme 57xx Gigabit Controller"
					 
                    NetwerkSnelheid = LeesVerbindingsSnelheid (strKeyPath & "\" & subkey, "RequestedMediaType", strComputer, strValue)
					
					If NetwerkSnelheid = "0" Then                     
							DuplexSnelheid = "Auto Detect"
						End If
					 
						If NetwerkSnelheid = "3" Then 
							DuplexSnelheid = "10 Mbps/Half Duplex"
						End If
					 
						If NetwerkSnelheid = "4" Then 
							DuplexSnelheid = "10 Mbps/Full Duplex"
						End If
					 
						If NetwerkSnelheid = "5" Then 
							DuplexSnelheid = "100 Mbps/Half Duplex"
						End If					 
					 
						If NetwerkSnelheid = "6" Then 
							DuplexSnelheid = "100 Mbps/Full Duplex"
						End If

						logfile.WriteLine "  Netwerk snelheid voor Broadcom NetXtreme Gigabit Ethernet staat ingesteld op: " & DuplexSnelheid
					
                    Exit Sub					
					
                Case "HP NC7781 Gigabit Server Adapter"
                    WScript.Echo "** Controleer de netwerk instelling handmatig! **"
                    Exit Sub
                Case "HP NC7782 Gigabit Server Adapter"
                    WScript.Echo "** Controleer de netwerk instelling handmatig! **"
                    Exit Sub
                Case "Intel(R) 82540EM Based Network Connection", _
					 "Intel(R) 82567LF Gigabit Network Connection", _
                     "Intel(R) PRO/100 VE Network Connection", _
                     "Intel(R) PRO/100 VM Network Connection", _
                     "Intel(R) PRO/1000 EB Network Connection with I/O Acceleration", _
					 "Intel(R) PRO/1000 GT Network Connection", _
					 "Intel(R) PRO/1000 GT Desktop Adapter", _
					 "Intel(R) PRO/1000 CT Network Connection", _
					 "Intel(R) PRO/1000 EB Network Connection with I/O Acceleration", _
					 "Intel(R) PRO/1000 PL Network Connection", _
                     "Intel(R) PRO/1000 MT Network Connection"
					 
                     NetwerkSnelheid = LeesVerbindingsSnelheid (strKeyPath & "\" & subkey, "SpeedDuplex", strComputer, strValue)		 
					 

						If NetwerkSnelheid = "0" Then 
							DuplexSnelheid = "Auto Detect"
						End If
					 
						If NetwerkSnelheid = "1" Then 
							DuplexSnelheid = "10 Mbps/Half Duplex"
						End If
					 
						If NetwerkSnelheid = "2" Then 
							DuplexSnelheid = "10 Mbps/Full Duplex"
						End If
					 
						If NetwerkSnelheid = "3" Then 
							DuplexSnelheid = "100 Mbps/Half Duplex"
						End If					 
					 
						If NetwerkSnelheid = "4" Then 
							DuplexSnelheid = "100 Mbps/Full Duplex"
						End If
					 
						If NetwerkSnelheid = "5" Then 
							DuplexSnelheid = "Auto-Negotiate 1000Mbps"							
						End If	

						logfile.WriteLine "  Netwerk snelheid voor Intel(R) PRO/1000 CT Network Connection staat ingesteld op: " & DuplexSnelheid
					 
                     Exit Sub
					 
                Case "Marvell Yukon 88E8055 PCI-E Gigabit Ethernet Controller"
                    NetwerkSnelheid = LeesVerbindingsSnelheid (strKeyPath & "\" & subkey, "ConnectionType_A", strComputer, strValue)
                    Exit Sub
                Case "NVIDIA nForce Networking Controller"
                    NetwerkSnelheid = LeesVerbindingsSnelheid (strKeyPath & "\" & subkey, "ForceSpeedDpx", strComputer, strValue)
                    Exit Sub
                Case "Realtek RTL8139C+ Fast Ethernet NIC"
                    WScript.Echo "** Controleer de netwerk instelling handmatig! **"
                    Exit Sub
                Case Else
                    blnNicFound = False					
            End Select			
			
			
        Next		
        
        If Not blnNICFound Then
            WScript.Echo "Geen, of onbekende netwerkkaart gevonden op " & strComputer
        End If
        
    End If
	
 End Sub

 
Whatever you see can only be illusion. Stop the resume next after the first check on the error object, and let the script error so that you see what is in store.
[tt]
'etc etc
If Err Then
WScript.Echo("Fout tijdens het lezen van het register op: " & strComputer)
Exit Sub
Else
[red]on error goto 0[/red]
strKeyPath = "System\Currentcontrolset\Control\Class\{4D36E972-E325-11CE-BFC1-08002be10318}"
'etc etc
End If
[/tt]
 
you can read the contents of the driver .inf file for the NICs to determine the integer values relating to each specific speed. so you wouldnt also need to maintain these values...hardcoded in your script. you wouldnt even need to maintain anything about the NIC types you support. you just find the nic you are using, grab its driver .inf file and read the details.
if you didnt want to go this route and you still wanted to maintain the data yourself (for other reasons) then i would highly recommend something lilke
xml file (in your global build / provisioning /packaging data file)
<supported_nics>
<supported_nic name="Intel(R) PRO/1000 MT Network Connection">
<speeds>
<speed>
<description>Auto Detect</description>
<value>0</value>
</speed>
....
</speeds>
</supported_nic>
....
</supported_nics>
'''or something like that

in doing so your code would contain no biz logic or data.
in order to implement change in the future you wouldnt need to change your code you could just update your data.
you can report on the supported cards and properties etc by transforming your data, rather than having to look in the your code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top