How do I change a group policy setting via cmd?

Solution 1:

The "Turn Off Autoplay" policy option can be enabled or disabled via the registry. It is very strongly recommended to leave it as disabled, as it is known to be used by viruses.

In Windows 10, total disable/enable of AutoPlay is via the registry at:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers
DisableAutoplay - REG_DWORD
Value:1 = AutoPlay disabled
Value:0 = AutoPlay enabled

It can be more finely set in the registry by two keys in HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER, meaning in either the Computer Configuration and User Configuration folders. If the policy settings conflict, the policy setting in Computer Configuration takes precedence over the one in User Configuration.

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer

The NoDriveTypeAutoRun item is of type REG_SZ and is composed of the following bits as required:

Value Meaning
0x1 Disables Autoplay on drives of unknown type.
0x4 Disables Autoplay on removable drives.
0x8 Disables Autoplay on fixed drives.
0x10 Disables Autoplay on network drives.
0x20 Disables Autoplay on CD-ROM drives.
0x40 Disables Autoplay on RAM disks.
0x80 Disables Autoplay on drives of unknown type.
0xFF Disables Autoplay on all types of drives.

Microsoft counsels against enabling AutoPlay, so the rules may change from one Windows version to the next, but always in the direction of making it harder to use.

Reboot is required after any registry change of these items.