🐍 Python 3.10+
Disable Autoplay for All Drives (Python)
Disables Autoplay prompts for every drive type, including USB. Applies the tweak via the stdlib winreg module.
set_disable_autoplay_all_drives.py
#!/usr/bin/env python3
"""
set_disable_autoplay_all_drives.py
Disable Autoplay for All Drives.
Disables Autoplay prompts for every drive type, including USB.
Usage:
python set_disable_autoplay_all_drives.py
"""
import winreg
def main() -> None:
key = winreg.CreateKeyEx(
winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", 0, winreg.KEY_SET_VALUE
)
winreg.SetValueEx(key, "NoDriveTypeAutoRun", 0, winreg.REG_DWORD, 255)
winreg.CloseKey(key)
print("Disable Autoplay for All Drives applied.")
if __name__ == "__main__":
main()