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

Dearest Fellow Monks,
I am using a licence restricted software that uses a USB dongle. I have several dongles and licence files as well as a save disabled demo licence. The software automatically picks the suitable licence. It has in the past occurred that the software was loaded with a dongle having been removed and after hours of changes a user suddenly realized that they could not save.
All these machines are running a tool based on Active States's PerlTray, that monitors certain conditions in order to automate some admin tasks. I was wondering if there is the remote chance that I can identify if a certain USB device is installed and warn the user if this is not the case while a process of relevant programm exists.
I have no problems checking for the PID, but I do not know how I can identify the USB device. Any help with this is greatly appreciated.

Cheers,
PerlingTheUK

Replies are listed 'Best First'.
Re: Checking for a USB Dongle
by Illuminatus (Curate) on Oct 04, 2007 at 23:09 UTC
    Did you look at Device::USB on cpan? I am assuming that you are running on Windows. There is information there on what needs to be done to get this module to work on Windows.
Re: Checking for a USB Dongle
by Firefly258 (Beadle) on Oct 06, 2007 at 04:18 UTC

    If you are on windows you could use WMI to query the Win32_USBControllerDevice and Win32_PnPEntity classes.

    Here is a howto in WSH, it'd take a little translating to perl using the WMI functionality in the Win32::OLE package.

    How Can I Determine Which USB Devices are Connected to a Computer?



    perl -e '$,=$",$_=(split/\W/,$^X)[y[eval]]]+--$_],print+just,another,split,hack'er