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
:
: 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
:
:
: 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
:
Regards,
reddy
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.