@arex21/usb-guard
v1.0.4
Published
Block USB storage devices (disks/flash drives) on Windows while keeping mouse/keyboard working. Prebuilt Windows binary.
Maintainers
Readme
USB Guard
Block USB storage devices (external HDDs, flash drives, etc.) on Windows while keeping your mouse and keyboard fully working. USB Guard installs itself as a Windows service that auto-blocks newly plugged-in storage devices, and can re-enable everything with a single command.
Features
- Blocks USB storage devices (matched by
USBSTOR/USB\CLASS_08) — disks and flash drives. - Keeps mouse, keyboard, and their ancestor hubs safe (they are never disabled).
- Runs as an auto-start Windows service so devices plugged in later get blocked too.
- One-command start (install + run) and stop (stop + re-enable + uninstall).
- Requires administrator privileges (auto-relaunches elevated via
runasif needed).
Install (as a CLI via npm)
npm i -g @arex21/usb-guardThis downloads a prebuilt Windows (win32-x64) binary.
Usage
USB Guard - block USB storage devices (disks/flash drives)
Usage:
usb-guard start - Start blocking the usb ports for storage devices
usb-guard stop - Allow ports to be allocated for storage device
Credits:
Created by: Arex
LinkedIn : https://www.linkedin.com/in/muhammad-owais-678622405/
Email : [email protected]Commands
| Command | What it does |
| --- | --- |
| usb-guard start | Installs the UsbGuard service and starts it. The service continuously blocks USB storage. |
| usb-guard stop | Stops the service, re-enables all previously blocked USB devices, and uninstalls the service. |
Both commands automatically request administrator elevation.
How it works
start→install(creates theUsbGuardauto-start service) +sc start UsbGuard.- The service scans the PnP device tree every ~30s, disabling only USB storage devnodes. Mouse/keyboard devnodes and every ancestor hub above them are protected.
stop→sc stop UsbGuard+ re-enables all disabled devices (including phantom ghost disk nodes) and re-enumerates the bus to remount volumes + uninstalls the service.
Credits
- Created by: Arex
- LinkedIn: https://www.linkedin.com/in/muhammad-owais-678622405/
- Email: [email protected]
License
MIT
