C program to Block/ Unblock the USB drive



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.