📊 VBA (Excel)
Apply Disable Autoplay for All Drives (VBA)
Disables Autoplay prompts for every drive type, including USB. Applied via WScript.Shell.RegWrite from VBA.
DisableAutoplayAllDrivesRegSet.bas
Attribute VB_Name = "DisableAutoplayAllDrivesRegSet"
Option Explicit
Public Sub DisableAutoplayAllDrivesRegSet()
Dim wsh As Object
Dim regPath As String
Set wsh = CreateObject("WScript.Shell")
regPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun"
wsh.RegWrite regPath, 255, "REG_DWORD"
MsgBox "Disable Autoplay for All Drives applied." & vbCrLf & regPath, vbInformation
End Sub