📜 VBScript (WSH)

Disable Autoplay for All Drives (VBScript)

Disables Autoplay prompts for every drive type, including USB. Applies the tweak via WScript.Shell.RegWrite.

By WindowsScripting.com · 737 B
SetDisableAutoplayAllDrives.vbs
' ============================================================
' SetDisableAutoplayAllDrives.vbs
'
' Disable Autoplay for All Drives.
' Disables Autoplay prompts for every drive type, including USB.
'
' Usage: cscript SetDisableAutoplayAllDrives.vbs
' ============================================================

Option Explicit

Dim objShell
Set objShell = CreateObject("WScript.Shell")

On Error Resume Next
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun", 255, "REG_DWORD"

If Err.Number = 0 Then
    WScript.Echo "Disable Autoplay for All Drives applied."
Else
    WScript.Echo "Failed to apply tweak (Error " & Err.Number & ": " & Err.Description & ")"
End If
On Error Goto 0