This article explains how to disable AutoRun in Windows by editing the Windows Registry and how to disable AutoPlay in Windows 10, 8.1, and 8.
How to Disable Auto Open USB in Windows 10 | Windows 10 Autoplay Settings
The Windows AutoRun feature allows programs to run from external devices as soon as the device is connected to your computer. Because malware can abuse AutoRun, many users disable it. There is no interface setting to completely disable AutoRun. Instead, you edit the Windows registry.
Press Win+R and type regedit to launch the Registry Editor. You will need to confirm elevated privileges to change registry settings.
If the NoDriveTypeAutoRun entry does not appear, create a new DWORD value by right-clicking in the right pane to open the context menu and selecting New DWORD (32-bit) Value.