How can I disable autoplay using PowerShell?

July 29, 2025 4 answers
Asked by CoolCat1234
I'm trying to turn off autoplay and set it to 'take no action' for all related settings through PowerShell. I attempted running a command like `New-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer -Name NoDriveTypeAutoRun -value 255 -type Dword`, but it didn't work as expected. Can anyone help me with this?

Answers

RegistryRanger
Just a heads up, I've heard that while this method works to change the setting, it might not be reflected in the UI. So, double-check to see if the registry key actually updated correctly.
Reply to this answer
ScriptMaster
Hereโ€™s a more comprehensive script you could try: ```powershell # Run as Administrator $regPath = "HKLM:SOFTWAREMicrosoftWindowsCurrentVersionPoliciesExplorer" # Ensure the registry path exists if (!(Test-Path $regPath)) { New-Item -Path $regPath -Force } # Set NoDriveTypeAutoRun to disable autoplay for all drive types Set-ItemProperty -Path $regPath -Name "NoDriveTypeAutoRun" -Value 255 -Type DWord # Also set NoAutorun for extra safety Set-ItemProperty -Path $regPath -Name "NoAutorun" -Value 1 -Type DWord # Restart Windows Explorer to apply changes Stop-Process -Name explorer -Force Start-Process explorer ``` Give this a shot and see if it helps!
Reply to this answer
WindowsWhiz
I ran that code on my system, and it worked perfectly to set the key to `0xFF`. What specific problems are you running into?
Reply to this answer
TechGuru99
When you say "didn't work", what did you experience? Did the command error out, not change anything, or did it just not have the desired effect? Also, make sure that the value you set is correctโ€”sometimes it can be `0xff` instead of `255`. And donโ€™t forget to run PowerShell as an administrator if you haven't already!

CuriousCoder56: Good point! Definitely check your permission levels and the exact value you're setting. Seeing the before and after might also offer some insights. Have you validated your registry keys?

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions