Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How do you enable/disable a driver in Windows?

by DrWhy (Chaplain)
on Feb 06, 2007 at 09:17 UTC ( [id://598502]=note: print w/replies, xml ) Need Help??


in reply to Re: How do you enable/disable a driver in Windows?
in thread How do you enable/disable a driver in Windows?

I'm far from being a Windows guru, so feel free to correct me if I'm wrong, but I'm not sure services are what I'm talking about. I want to turn off the driver software that allows the OS to recognize and communicate with a USB device (actually a specific type of USB device, but that's probably not relevant). Is it possible that each device driver also has a service associated with it that? I've not seen that before. What I'm talking about is doing what you would normally do by hand by going to the System control panel, clicking on the 'Hardware' link and then drilling down to the details for the specific driver in question and then selecting 'disable' from the dropdown menu at the bottom of the window.

--DrWhy

"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

  • Comment on Re^2: How do you enable/disable a driver in Windows?

Replies are listed 'Best First'.
Re^3: How do you enable/disable a driver in Windows?
by BrowserUk (Patriarch) on Feb 06, 2007 at 13:36 UTC

    Yes. You are looking to disable a device driver, not a service.

    The particular APIs needed do this are located in DEVMGR.DLL, probably one of DeviceProperties(A|W), or DevicePropertiesEx(A|W) or DeviceAdvancedProperties(A|W). However, these APIs are officially undocumented, so working out what the parameters are would be extremely difficult.

    There are various hardware and DD developer kits available that provide (indirect but documented) access to these APIs, (Windows Device Testing Framework (WDTF); Device Driver Kits (DDKs); WDK etc. ), but which one you would need and whether it would cost money depends upon the version and age of the OS etc. I assume this is not the route you are looking to take.

    BTW. The description you give of how to do this manually indicates that you are working with a fairly old version of Windows? On XP (and I think on 2000/2003), the interface changed. You now do this manually via:

    Administrative tools->Computer management->Device Manager

    That means that it may be possible to adjust these settings programmatically via the Windows Management Interface (WMI) on these later systems--but that probably doesn't help if you're working with NT or earlier.

    It's also possible to disable them by adjusting the values of the appropriate registry entries (Win32API::Registry), but I think that you then need a re-boot for it to take affect.

    Ultimately, I'm guessing that what you are trying to do is disable the use of USB thumb drives and similar "security risk" devices for corporate desktops? If so, the best way is to do this through the application of appropriate group policies and articles of this nature may be more appropriate to your needs.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thanks for the detailed information. I'm actually on XP. I may have confused you because I forgot and left out a step; in the hardware tab of the system control panel I click on another button -- 'Device Manager', I think, but I'm on a Mac system right now so I'm still going from memory. I'm interested in a solution that will work on Win2k and above since that is the range of OS's that our software supports.

      I'm writing a set of tests for our software to see how it behaves when a USB security hasp is removed/not present. Our software is only supposed to work when the hasp is present.

      In doing some more digging around on the internet I found an MSDN article that pointed to a command line utility, devcon, that does most of what the Device Manager control panel does, but from the command line. It can be downloaded here. Should be straightforward to write a perl wrapper around that, much easier than trying to muck with WMI. Curious, though in doing some reading on WMI, my impression was that it was only useful for querying information about the system setup. It didn't seem to me that you could use it to effect changes to the system configuration.

      Update: Just noticed that devcon.exe is part of the DDK package you mentioned.

      Update: The x64/amd64 version of this tool is not included in the link I mentioned above. It's only available, afaict, as part of the newer Windows Driver Kit.

      --DrWhy

      "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://598502]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2025-03-16 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (54 votes). Check out past polls.