Home: Perl Programming Help: Win32 Programming Help:


Aug 8, 2002, 7:15 AM

Views: 9910

I want to get the MAC address. The problem is it returns the correct MAC address that i want i.e 00:04:76:DC:D6:EC but it also returns another (when the foreach loops again) 50:50:54:50:30:30. I only want the first one. Does anyone know what this second part is ?

I tryed to get round it by putting this $varible in to an array. However when i do this it adds both strings to element[0].

Is there a way to write the code below so it is not in a loop ? Or any other way to get round this problem?

Heres my code snippet. Im trying to gather system information.

#Get MAC Address
foreach $Object (in ($WMIServices->InstancesOf( "Win32_NetworkAdapter" ) ) ) {
$MAC = ($Object->{MACAddress});
print" $MAC";

Cheers for any hints, tips, or explanations.


Aug 9, 2002, 7:51 AM

Views: 9907
Re: [Bode] "Win32_NetworkAdapter"

can i see the rest of your code (looks intersting)?
How do you create $WMIServices ... what module are you using?
Please share

now as to your question,
on my win2000 i got at least 10 network adapters,
and I suppose most people have at least 2.
I don't see this as a problem
( the first adapter in the list is probably the current in use)