Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How disable and enable usb port via command prompt?

How disable and enable usb port via command prompt? or using batch script ? or using vb script in windows 7?

like image 971
open source guy Avatar asked Nov 07 '12 09:11

open source guy


People also ask

How do I disable and enable USB ports?

Enable or Disable Usb Ports Through Device ManagerRight-click on the “Start” button on the taskbar and select “Device Manager”. Expand USB Controllers. Right-click on all entries, one after another, and click “Disable Device”. Click “Yes” when you see a confirmation dialog.


2 Answers

You can also have a look at devcon command. Available freely on microsoft site, for win7+ windows.

like image 38
anishsane Avatar answered Sep 22 '22 14:09

anishsane


You can use batch which gives you a couple of options. You can edit the registry key to disable usb devices from being used

reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "4" /f

To enable change value to 3.

Or you can deny access to the files Usbstor.pnf and Usbstor.inf

cacls %windir%\Inf\Usbstor.pnf /d user
cacls %windir%\Inf\Usbstor.inf /d user

Where user is the user account that you want to deny access for.

To enable use

cacls %windir%\Inf\Usbstor.pnf /p user:R
cacls %windir%\Inf\Usbstor.inf /p user:R

Both commands will need admin rights.

Hope this helps

like image 112
Bali C Avatar answered Sep 24 '22 14:09

Bali C