Skip to content

AutoRun and AutoPlay

AutoRun executes a program automatically when removable media is inserted. AutoPlay pops up a menu offering to. Together they're how USB-borne malware spreads: plug in the drive, the malware runs. Turn both off for every drive type.

Where it is

gpedit.mscComputer ConfigurationAdministrative TemplatesWindows ComponentsAutoPlay Policies.

Setting Value
Turn off AutoPlay (18.10.8.3) Enabled, All drives
Set the default behavior for AutoRun (18.10.8.2) Enabled, Do not execute any autorun commands
Disallow AutoPlay for non-volume devices (18.10.8.1) Enabled

The Settings app has a simpler switch (SettingsBluetooth & devicesAutoPlay) but it's per-user. Policy covers everyone.

Step by step

  1. Open gpedit.msc.
  2. Navigate to AutoPlay Policies.
  3. Double-click Turn off AutoPlayEnabled → in the dropdown choose All drivesOK.
  4. Double-click Set the default behavior for AutoRunEnabledDo not execute any autorun commandsOK.
  5. Double-click Disallow AutoPlay for non-volume devicesEnabledOK.
  6. Run gpupdate /force.

Verify

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDriveTypeAutoRun
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoAutorun

NoDriveTypeAutoRun should be 0xff (255, all drive types). NoAutorun should be 1.

Next

PowerShell Execution Policy