batch files to enable and disable usb port and cd


Would it be possible to write a MS Dos batch file to enable/disable the usb port and/or CD drive.

Who is Participating?
waleedaConnect With a Mentor Commented:
for disable use the below script and batch file

1st File: Disable USB.bat

@echo off
regedit /s 4.reg

subinacl.exe /keyreg \system\currentcontrolset\services\usbstor /deny=system
subinacl.exe /keyreg \system\currentcontrolset\services\usbstor /deny=Administrators

echo **USB drives disabled**


2nd File: 4.reg

Windows Registry Editor Version 5.00


make sure that you added "subinacl.exe" in the same folder while you are applying this script
MS DOS batch file, No... Your best approach to this would be to use WSH scripting to edit the local security policy settings do enable / disable access to the drives.

See: - editing the registry

I don't know the exact registry items to create / edit to enable / disable the drives...
Lionel MMSmall Business IT ConsultantCommented:
You say you would to enable and disable a USB port--do you mean a USB drive or the USB port itself? Is the CD drive you want to enable/disable a removable drive or a fixed internal rive?
WEBINAR: GDPR Implemented - Tips & Lessons Learned

Join the WatchGuard team on Thursday, March 29th as we recount some valuable lessons learned in weighing the needs of a business against the new regulatory environment, look ahead at the two months left before implementation, and help you understand the steps you can take today!

PipMicAuthor Commented:

I meant disabling the use of a usb device. as regards the cd drive its a fixed internal drive.

PipMicAuthor Commented:
Would have preferred some explanantion, but i suppose i didnt ask for it!!
bryan vanderveenCommented:
Lol that is really clear. When he says the steps, he starts out with what you need to name the files. You need to open a new text document for each one and past the script to the text document. After that click file and save as. Then use the title he gave u in the beginnings of the steps and select All Files then save. A file will appear, click on all the files u made.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.