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\NoDriveTypeAutorunHKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutorunThis 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\DisableAutoplayHKCU\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\DisallowAutoplayForNonVolumeDevicesHKLM\SOFTWARE\Microsoft\PolicyManager\default\Autoplay\SetDefaultAutoRunBehaviorHKLM\SOFTWARE\Microsoft\PolicyManager\default\Autoplay\TurnOffAutoPlayHKLM\SYSTEM\CurrentControlSet\Services\cdrom\HKLM\SYSTEM\CurrentControlSet\Services\Disk\HKLM\SYSTEM\CurrentControlSet\Services\sfloppy\ 1 Answer
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutorunis 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.