in reply to Re: WindowsRegistry{ServiceName} V.S. wmic{ServiceName}
in thread WindowsRegistry{ServiceName} V.S. wmic{ServiceName} UPDATE: Solved

That does not correspond, on my machine.

I suppose you could read all the subkeys of

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards
then match $node{Name} to the first value contained in the "Description" of each subkey entry. Update: Working code that gets the GUID, if it exists:
use strict; use Win32::TieRegistry; use Data::Dumper; # Get nic info via wmic (not available on all versions of windows)... my @devs = split(/^\s*\n/m, `wmic nic list brief /format:value`); my %Regvalues; shift(@devs); # Remove initial blank line DumpReg(); Dumpwmic( $_ )for (0..15); sub Dumpwmic{ my $d = $devs[shift]; # Take the 2nd device my %node = split(/[=\n]/, $d); # Hashify information $node{Name} =~s/\s+$//; print Dumper(\%node); print $Regvalues{ $node{Name} } . "\n"; } sub DumpReg{ my $dev="LMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Netw +orkCards"; my $key=$Registry->Open($dev, { Access => "KEY_READ", Delimiter => +"/" } ); foreach my $subKey ( $key->SubKeyNames ) { $Regvalues{ $key->{$subKey}->{Description} } = $key->{ $subKey +}->{ServiceName}; print "$subKey=" . $key->{$subKey}->{Description} . " " . $key->{ $subKey}->{ServiceName} . "\n"; } }

     "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom

Replies are listed 'Best First'.
Re^3: WindowsRegistry{ServiceName} V.S. wmic{ServiceName}
by cmv (Chaplain) on Sep 20, 2007 at 13:53 UTC
    Many thanks NetWallah for the great update! Your use of the correct term for the hex servicename (GUID), jogged my memory on when I last looked into this stuff. I may be able to dig up something from the past.

    Here is the problem I asking for direction with now:

    On my machine, "wmic nic list brief" gives me 22 devices:

    However, looking at the registry with the following code, I only get information on 3 of the devices: I would like to get the GUID for a device that doesn't appear in the registry. How do I do this?

    Anticipating a possible answer: If the GUID doesn't exist, how can I get one created for a given device?

    Many, many, thanks!

    -Craig

      Sorry - that is a bit deeper into the network stack and Registry interaction than I have dived.

      In fact, I am not comfortable with the code I posted, because I do not understand the interaction between "wmic nic" information and the registry location (which was pointed out by ikagami, I believe. To me, the code is a hack, and there ought to be a better way (but I do not have the time or motivation to research it).

      I'm not sure it is meaningful to invent and attach GUIDs to devices that Windows does not care enough about to assign GUIDs.

           "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom