1

I want to add a few lines to a script with the capacity to enable/disable the Autorun feature.

It's not a new concept. It's been covered countless times before, including here on StackExchange, and here by Microsoft.

The general consensus is, it's achieved by modifying the values of the following registry keys:

HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutorun

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutorun

This worked for me in the past with Windows7 (Ultimate/Professional), but these registry keys don't appear to be present on Windows10 (Enterprise). Is this normal? Have they been superseded?


I did a search for related keywords and found the following that seem like they could be relevant.

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\DisableAutoplay

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlersDefaultSelection\AutorunINFLegacyArrival\
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\UserChosenExecuteHandlers\AutorunINFLegacyArrival\

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers\AutorunINFLegacyArrival\
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers\MSAutoRun\
HKLM\SOFTWARE\Microsoft\PolicyManager\default\Autoplay\DisallowAutoplayForNonVolumeDevices
HKLM\SOFTWARE\Microsoft\PolicyManager\default\Autoplay\SetDefaultAutoRunBehavior
HKLM\SOFTWARE\Microsoft\PolicyManager\default\Autoplay\TurnOffAutoPlay
HKLM\SYSTEM\CurrentControlSet\Services\cdrom\
HKLM\SYSTEM\CurrentControlSet\Services\Disk\
HKLM\SYSTEM\CurrentControlSet\Services\sfloppy\

1 Answer 1

1
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutorun

is still the correct registry key to disable Autorun.
This can be proven by going into the local policy editor and navigating to:
User / Computer Configuration -> Administrative Templates-> Windows Components -> Turn off Autoplay

Setting this policy to "CD-ROM and removable media drives" will change to the value 181 (0xb5), setting it to "All drives" will change the value to 255 (0xff).
The registry key most likely doesn't exist on your system because it has never been configured via group policies.

I can confirm that with the policy configured and the value set to 255 I no longer got a notification when inserting a DVD. This was tested with an Insider preview of Windows Server 2019 but should still apply to Windows 10.


Another possibility is to create the REG_DWORD

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\DisableAutoplay
Value:1 = AutoPlay disabled
Value:0 = AutoPlay enabled


to disable AutoPlay for the current user. This is the same value that is used by the modern settings app located under Devices -> AutoPlay -> Use AutoPlay for all media and devices.

The advantage of using this method is that it should work on all versions of Windows 10 because its a native setting and no policy.
A mayor disadvantage may be that user will still be able to change the setting by them self since its no policy.
Also this method wont allow you to only block certain removable media while NoDriveTypeAutorun allows finer configurations.

7
  • If I just add it manually, will it have the desired effect?
    – voices
    Nov 25, 2018 at 19:38
  • Yes that should work, most Group Policies literally just set a registry key. In my case Autorun got disabled immediately (no restart of explorer or Windows required)
    – User025
    Nov 25, 2018 at 19:50
  • Worth pointing out that some group policies only work on certain editions. So changing the associated registry key would not work in a case where the group policy wasn't applicable to the edition you are using. However, that isn't the case with this particular policy, but worth pointing out if you are trying to set group policies through the registry.
    – Ramhound
    Nov 28, 2018 at 14:34
  • @Ramhound Are there any Group Policies that wont work in the Enterprise version of Windows? Thought they would all work for that version so I didn't mention that.
    – User025
    Nov 28, 2018 at 16:17
  • @User025 - There are indeed group policies that are ignored if enabled on Windows 10 Professional and are only applicable to Windows 10 Enterprise. Please read my original comment again.
    – Ramhound
    Nov 28, 2018 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .