in reply to Re: WindowsRegistry{ServiceName} V.S. wmic{ServiceName}
in thread WindowsRegistry{ServiceName} V.S. wmic{ServiceName} UPDATE: Solved
I suppose you could read all the subkeys of
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCardsthen 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 | |
by NetWallah (Canon) on Sep 20, 2007 at 21:57 UTC | |
by ddn123456 (Pilgrim) on Sep 21, 2007 at 07:06 UTC |