đź“„ JScript (WSH)

Disable Autoplay for All Drives (JScript)

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

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

var objShell = WScript.CreateObject("WScript.Shell");

try {
    objShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoDriveTypeAutoRun", 255, "REG_DWORD");
    WScript.Echo("Disable Autoplay for All Drives applied.");
} catch (e) {
    WScript.Echo("Failed to apply tweak: " + e.description);
}