Disabling/Enabling Hardware

Posted on 2010-01-05
Last Modified: 2012-05-08
How can I disable a hardware, then re-enable it through VB6 or VB.NET?

I am using a USB-Serial converter and the problem is it sometimes hangs. The converter will work again by unplugging, then replugging it, or simply by disabling then re-enabling it in the device manager. I want the unit to be disabled and re-enabled automatically after detecting that it's not working.

P.S. I prefer the code to be in VB6 because it is an old application and I prefer not to install .NET Framework just for this function. But if not possible, a code in .NET will do since I really need to get this done.
Question by:Thomasian
    LVL 48

    Expert Comment

    LVL 22

    Author Comment


    Thanks for the link.

    We have the same problem but the solution seems to just start/stop the device manager and not the USB flash drive. Don't know why it was accepted though..
    LVL 41

    Accepted Solution

    Yes, you can perform the same kind of steps to disable/wait/enable a device via a VB program... but will be tough.  It will require lots of low-level API calls.
    On the other hand, you might be able to just have your applicaiton "shell out" to run the DEVCON utility to preform the same thing.   It's look some like this:
    Shell("devcon disable SomeUglyLookingDeviceID")
    Shell ("Devcon enable SameUglyDeviceID")
    LVL 22

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now