Blog Archive

Wednesday, December 29, 2010

How To Write A C Program To Disable USB Devices

In this Post I will Teach U How To Make A Program Which Disable Ur All USB Ports.

Which U use To insert PEndrvie/Flashdrive

Using C\C++ Langauge.

First of all you need a 32 bit compiler for that.
For this example you can use microsoft Visual C++ compiler or
BloodShed's Dev C++ which is a free compiler for c and C++.
You can download Dev-C++ from following link:
http://www.blooodshed.net/download.html

So lets write the code. The following code will disable all usb ports of your computer.

BlockUSB.c

#include<stdio.h>

void main()
{
system("reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 4 \/f");
}

Compile and run above code. And then insert your usb pendrive, pendrive will not gonna be work.

To Re-Enable Usb Ports Compile and run following code.
UnBlockUsb.c

#include<stdio.h>

void main()
{
system("reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 3 \/f");
}

No comments:

Post a Comment