需求:禁止所有 USB 大量儲存裝置 (隨身碟、行動硬碟、手機儲存模式),**但保留 USB HID (滑鼠/鍵盤)、印表機、掃描儀、加密狗 (HASP/SENTINEL) 等非儲存類裝置正常運作**。
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTORStart (DWORD) = 4 (Disabled) — 預設 3 (Manual)%Windir%\inf\usbstor.inf%Windir%\inf\usbstor.pnfHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies (無則新增)WriteProtect (DWORD) = 1@echo off
reg add "HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t REG_DWORD /d 4 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" /v WriteProtect /t REG_DWORD /d 1 /f
copy "%Windir%\inf\usbstor.inf" "%Windir%\usbstor.inf" /y >nul
copy "%Windir%\inf\usbstor.pnf" "%Windir%\usbstor.pnf" /y >nul
del "%Windir%\inf\usbstor.inf" /f /q >nul
del "%Windir%\inf\usbstor.pnf" /f /q >nul
echo USB儲存裝置已禁用 (滑鼠/鍵盤/印表機/加密狗不受影響)
pause
@echo off
reg add "HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t REG_DWORD /d 3 /f
copy "%Windir%\usbstor.inf" "%Windir%\inf\usbstor.inf" /y >nul
copy "%Windir%\usbstor.pnf" "%Windir%\inf\usbstor.pnf" /y >nul
del "%Windir%\usbstor.inf" /f /q >nul
del "%Windir%\usbstor.pnf" /f /q >nul
echo USB儲存裝置已啟用 (仍受WriteProtect限制,如需寫入請手動將WriteProtect設0)
pause
法律/合規提醒:企業部署前請審閱當地勞動法規、隱私法、資安政策,告知員工並簽署同意書。