cmv has asked for the wisdom of the Perl Monks concerning the following question:

Folks-

I have an Lenovo (IBM) Thinkpad T60, containing (among other things) an internal wired ethernet interface. My power management is such that when this machine is powered up on battery, with no ethernet connection, the network adapter is not powered up. When this happens, the device does not appear in the device manager, and I cannot query it for its MAC address as described in WIN32: Permanent & Current MAC Addresses.

Taking the laptop off of battery signals power management to change its policy, and the device is automatically powered up, even when still disconnected from the network. However, I need to be able to query for the MAC address at any time the machine is available.

How can I use perl to tell this machine to power-up the device for me, so I can get the MAC address?

Thanks

-Craig

Replies are listed 'Best First'.
Re: WIN32: How to power-up a device?
by mr_mischief (Monsignor) on Sep 26, 2007 at 17:48 UTC
    What software are you running that changes the apparent MAC address? The one that's permanently assigned to the interface is, well, permanent.

    Unless you're assigning something else at the network stack level (in which case there should be the new MAC address in that software's configuration somewhere), then you only need to get the MAC address for a given network interface on the local machine once.

    I'd suggest something like c:\mymac.dat or c:\windows\system32\mymac.dat as a place to store the MAC address for when you're offline. That is, unless you're trusting a Perl program to do something sneaky like lock a user out if they install the software on another machine or change Ethernet cards. ;-)

      My software doesn't change the apparent MAC address, it wants to simply record the permanent MAC address of the machine it is running on when first started up.

      The current problem is if a laptop user first runs the software when their power management has shut down the ethernet hardware, it cannot go ahead and record it.

      Once it gets the address, it stores it in a file, similar to what you suggest.

      One easy solution would be to popup "Please connect your laptop to the network", but even I would get uncomfortable thinking it was going to transmit data somewhere, or something sneaky like that.

        Well if you have access to change the hardware profile that's being used, that's a good bet.

        You could also ask for a power connection instead of a network connection if you're worried about people thinking something is being submitted somewhere.

        You can also get MAC addresses from the registry (at least if it's been changed by the system admin -- I'm not sure if there's any record of it there when deaulting to the physical MAC).

        In short, I'm not sure you have a Perl problem so much as a Windows problem.

Re: WIN32: How to power-up a device?
by swampyankee (Parson) on Sep 26, 2007 at 16:31 UTC

    Before going into Perl, would it make sense to change the power management policy to keep the internet interface turned on?


    emc

    Information about American English usage here and here.

    Any Northeastern US area jobs? I'm currently unemployed.

      This is one fallback position. You can actually de-select "Allow the computer to turn off this device to save power" off of the Power Management tab of the device driver's properties.

      However, I'm hoping that I can find a way to avoid bothering the user with this. Well, ok, actually bothering me with providing the instructions to the user to do this.

      Hmmm, I wonder if there's an easy way to deselect this device driver property right from the perl script. Let me investgate a bit...