Programatically enable & disable USB port using C#.NET

Dear All,

i have developed a desktop based application using C#.NET.
In this application, i wants to enable & disable the USB drives programatically. ie, enable the USB port before the application starts using it & disable it after the use.
I need to achieve the same when the application is running in a login, who doesn't have administrative rights.

Is it possible to achieve the same using .NET framework?
Do any one knows how to implement this. If so, please inform me.

Best Regards,
Abhilash Chandran

Comments

  • : Dear All,
    :
    : i have developed a desktop based application using C#.NET.
    : In this application, i wants to enable & disable the USB drives programatically. ie, enable the USB port before the application starts using it & disable it after the use.
    : I need to achieve the same when the application is running in a login, who doesn't have administrative rights.
    :
    : Is it possible to achieve the same using .NET framework?
    : Do any one knows how to implement this. If so, please inform me.
    :
    : Best Regards,
    : Abhilash Chandran
    :



  • : Dear All,
    :
    : i have developed a desktop based application using C#.NET.
    : In this application, i wants to enable & disable the USB drives programatically. ie, enable the USB port before the application starts using it & disable it after the use.
    : I need to achieve the same when the application is running in a login, who doesn't have administrative rights.
    :
    : Is it possible to achieve the same using .NET framework?
    : Do any one knows how to implement this. If so, please inform me.
    :
    : Best Regards,
    : Abhilash Chandran
    :

  • please send me the code to enable the USB and how to run.


    Regards,
    reddy

  • pls send me this code
  • I tried some hack code to Win32 System device, but seem like they are all restricted ( or read only ) without Admin permission. I could not program this stuff in my own. the good news is we have one way to do it, but it wont be nice at all.

    Try this:
    1. Download Devcon file at http://support.microsoft.com/kb/311272 and add it to your project folder.
    2. Code:
    [code]

    using System.Diagnostics;
    ...

    //create Prcess start info object with devcon.exe
    ProcessStartInfo PSI = new ProcessStartInfo(@C:/Devcon/i386/devcon.exe);


    // disable an USB CDROM
    PSI.Arguments = @disable *USB*CDROM*;
    Process.Start(PSI);

    //enable USB CDROM
    PSI.Arguments = @enable *USB*CDROM*;
    Process.Start(PSI);
    ...

    [/code]

    // if you have specific devive ID or type such as Flash, Ipod, Samsung ....
    // you can replace it in "CDROM" expression

    It works without Administor permission 'cause .Net "trust" devcon.exe :)

    I'll let you know if i find other way.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories