Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Checking for a USB Dongle

by PerlingTheUK (Hermit)
on Oct 04, 2007 at 21:31 UTC ( [id://642774]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://642774]
Approved by ikegami
Front-paged by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found