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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: How do you enable/disable a driver in Windows? by BrowserUk
in thread How do you enable/disable a driver in Windows? by DrWhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.