With the help of batch programming we can enable or disable USB device in a single click.ACL permissions are also set during the process.
The script will enable the security permissions which will help us to modify certain registry keys, then modifies the required keys and reverts back the permissions.
First create four files as mentioned below.
0.reg
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR] "Start"=dword:00000004
1.reg
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR] "Start"=dword:00000003
SubInACL
Before proceeding further you need to download SubInACL (Incase if the link doesn’t work, google for ‘SubInACL’ to get the MS download link). This tool helps you to set ACL permissions for the registry keys through command line parameters.
@echo off cls regedit /s 0.reg subinacl.exe /keyreg systemcurrentcontrolsetservicesusbstor /deny=system subinacl.exe /keyreg systemcurrentcontrolsetservicesusbstor /deny=users subinacl.exe /keyreg systemcurrentcontrolsetservicesusbstor /deny=administrators echo. echo **Disabled** echo. //pause
@echo off cls subinacl.exe /keyreg systemcurrentcontrolsetservicesusbstor /grant=system subinacl.exe /keyreg systemcurrentcontrolsetservicesusbstor /grant=users subinacl.exe /keyreg systemcurrentcontrolsetservicesusbstor /grant=administrators regedit /s 1.reg echo. echo **Enabled** echo. //pause
After creating all the above mentioned files, put those in a directory. Make sure you have all the five files in the same directory (i.e 0.reg, 1.reg, enable.bat*, disable.bat* and subinacl.exe).
Now double click the batch file* to see it in action.
Note*:
-
Uncomment pause command to see the execution status in the command prompt.






