• Slide 1 Title

    Go to Blogger edit html and replace these slide 1 description with your own words. ...

  • Slide 2 Title

    Go to Blogger edit html and replace these slide 2 description with your own words. ...

  • Slide 3 Title

    Go to Blogger edit html and replace these slide 3 description with your own words. ...

  • Slide 4 Title

    Go to Blogger edit html and replace these slide 4 description with your own words. ...

  • Slide 5 Title

    Go to Blogger edit html and replace these slide 5 description with your own words. ...

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Thursday, 3 February 2011

C Program to Disable and Enable Usb Port





In this post I’m going to show you how we can Disable and Enable USB Port. By blocking the usb port we can control whether user to access the machine or not.

Many schools and colleges have no pen drive rule, for that they are blocking the usb port. This trick will help us to open the blocked usb port.

This is very small and easy code, once the block usb program executed the computer will not recognize any inserted usb drive, but we can reverse it by unblocking the usb port.

This program tested on XP but not sure about vista & windows 7. You can try this program on your own computer, as I have given the unblock code also

Logic of the program
The logic of the program is simple. The 'C' source file block_usb.c writes the DWORD value of 4 (100 in binary) in the registry settings at "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start" to 'lock' the USB ports.

Similarly, in the inverse process, the 'C' source file Unblock_usb.c writes the DWORD value of 3 (011 in binary) in the registry settings at "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Start" to 'unlock' the USB ports.


CODE
To disable usb port
#include<stdio.h>
void main()
{
system("reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 4 \/f");
}

Save this code as block_usb.c and open it with turbo c compiler, after compilation it will create a block_usb.exe which is a simple program that will disable (block) all the USB ports of the computer.

refer my article  To install turbo c compiler

After execution of block_usb.exe insert your pen drive, computer will not detect it. Now here’s the unblock code
To enable usb port
#include<stdio.h>
void main()
{
system("reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 3 \/f");
}

Save this code as unblock_usb.c and compile it with turbo c to get the unblock_usb.exe

Execute the unblock_usb.exe and now the computer detecting your pen drive.

I have also created rar file containing c source code of block and unblock usb and the executable files. Download from here


hope you liked this post, please comment below to express your feelings… :)
Categories:

0 comments:

Post a Comment

 
  • Recent Articles

  • Popular Articles

  • Recent Comments