2 Sep 2012

C program to Block/ Unblock the USB drive

Hi folks, here I'm sharing another code which I got from internet which helps to block/unblock your USB drive. This code is simply used to edit the windows registry values.

Code to Block the USB:

Open Notepad and copy this code.

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


Save as block.c, and compile this code. You'll get block.exe.
Execute this file to block the USB drive.

Code to Unblock the USB:

Open Notepad and copy below code.

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


Save as unblock.c, and compile this code. You'll get unblock.exe.
Execute this file to unblock the USB drive.

If you're having troubles in compiling this code then take a look at How To Compile a C code. For windows 7, run the file as administrator to make it effective.

Happy Coding. :)

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Online Project management