The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

Enable or Disable USB Port Using C Program

Enable and Disable USB Port in C Program

Normally, we have to go to control panel to enable or disable USB port. But C programming allow one to either enable or disable their USB port just by compiling the following c program.

C Program - To Disable USB Ports

Here is the c program to disable your USB port.

c-disable-usb.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
system( "reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 4 \/f" );
return 0;
}

C Program - To Enable USB Ports

Here is the C program to Enable your USB port

c-enable-usb.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
system( "reg add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR \/v Start \/t REG_DWORD \/d 3 \/f" );
return 0;
}

Note:

For security reason it won't work in windows 7 or later.

Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.

Report