Dr. Mu has asked for the wisdom of the Perl Monks concerning the following question:

I have a need to automate the installation of a USB serial driver in Windows XP. My installation program, written in Perl, will be run from a USB memory stick. Before the driver gets installed, a modification needs to be made to its .INF file. The information required to perform the mod is the two-digit USB "location ID" of the USB port that the installation memory stick is plugged into. Microsoft's usbview.exe program can provide this info, but it's strictly a GUI app, and there's no discernable way to get its output into a text file for Perl to parse. A search of CPAN came up blank -- unless I'm just looking for the wrong thing.

Any ideas?

Update: I now realize there's a flaw in the ointment. The idea was for the user to plug the memory stick into the USB port they were going to use for the serial adaptor. However, I now see that when a memory stick is plugged in, the port takes on an entirely different location ID than when a serial adapter is plugged in. This isn't going to work.

Replies are listed 'Best First'.
Re: Obtaining USB Location IDs
by kvale (Monsignor) on Apr 14, 2006 at 17:46 UTC
    Although not a Perl answer, this tech note has code for getiing the location ID.

    -Mark

Re: Obtaining USB Location IDs
by davidrw (Prior) on Apr 14, 2006 at 17:55 UTC
    I got usbview.exe from here ... maybe you can use Win32::CtrlGUI and Win32::Clipboard and do:
    LOOP: down arrow # move to next item in the tree in the left pane TAB # move focus to right pane ctrl-a # select all (though it might auto-highlight everyt +hing already) ctrl-c # copy to clipboard parse clipboard using Win32::Clipboard to look for what you need TAB # move focus back to left pane end loop when ???? get repeated text?? after 100 "down's"??