Disable USB AutoRun via the Registry

Turn off automatic execution for removable drives so inserted USB sticks never launch anything.

WindowsregistryusbsecurityMedium risk
Run the reg add command setting NoDriveTypeAutoRun to 255 in an admin Command Prompt; log off and back on to apply.

01Command

Command
$ reg add "HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesExplorer" /v NoDriveTypeAutoRun /t REG_DWORD /d 255 /f

02What it does

AutoRun was designed for convenience but became the infection vector of countless USB-borne worms, which is why modern Windows already limits it. Setting NoDriveTypeAutoRun to 255 disables it for every drive type, so plugging in a USB stick only opens Explorer or nothing at all. The default value 145 restores normal behavior.

03Risk

RiskMedium risk
RequirementsRun Command Prompt as administrator. Value 255 (0xFF) disables AutoRun on all drive types; 145 is the Windows default.
!Warning: This does not stop you from manually double-clicking a malicious file — treat unknown USB sticks as untrusted regardless.

04Undo

Undo
$ reg add "HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesExplorer" /v NoDriveTypeAutoRun /t REG_DWORD /d 145 /f

05Sources

Last verified: 2026-09-18 · Category: Security & Privacy

06Related solutions