Created
November 8, 2022 14:39
-
-
Save IamFaizanKhalid/4e9e8779255f9b0949e08c32e2b853fd to your computer and use it in GitHub Desktop.
Write-protect USB devices on a Windows PC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
pushd "%~dp0" | |
:A | |
echo. | |
echo 1. Set USB Devices as Read Only on this PC | |
echo 2. Set USB Devices as Read and Write on this PC | |
echo 3. Exit | |
echo. | |
set /p usbd=Choose an option : | |
SET _REG=reg add "HKLM\SYSTEM\ControlSet001\Control\StorageDevicePolicies" /f /t REG_DWORD /v WriteProtect /d | |
if "%usbd%"=="1" %_REG% 1 | |
if "%usbd%"=="2" %_REG% 0 | |
if "%usbd%"=="3" exit | |
set usbd= | |
echo Press any key to EXIT | |
pause>nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment