Last active
March 16, 2022 22:07
-
-
Save nsticco/2aa21134221e332d62e0b5976a388564 to your computer and use it in GitHub Desktop.
bootstrap-windows-sounds
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 Windows 10 or 11 System Sounds | |
########################################################################################## | |
# https://stackoverflow.com/questions/56619933/how-to-set-sound-scheme-to-no-sound-by-powershell | |
Write-Host "`nSetting Sound Schemes to 'No Sound' .." -foregroundcolor Gray | |
$Path = "HKCU:\AppEvents\Schemes" | |
$Keyname = "(Default)" | |
$SetValue = ".None" | |
$TestPath = Test-Path $Path | |
if (-Not($TestPath -eq $True)) { | |
Write-Host " Creating Folder.. " -foregroundcolor Gray | |
New-item $path -force | |
} | |
if (Get-ItemProperty -path $Path -name $KeyName -EA SilentlyContinue) { | |
$Keyvalue = (Get-ItemProperty -path $Path).$keyname | |
if ($KeyValue -eq $setValue) { | |
Write-Host " The Registry Key Already Exists. " -foregroundcolor green | |
} | |
else { | |
Write-Host " Changing Key Value.. " -foregroundcolor Gray | |
New-itemProperty -path $Path -Name $keyname -value $SetValue -force # Set 'No Sound' Schemes | |
Get-ChildItem -Path "HKCU:\AppEvents\Schemes\Apps" | # Apply 'No Sound' Schemes | |
Get-ChildItem | | |
Get-ChildItem | | |
Where-Object { $_.PSChildName -eq ".Current" } | | |
Set-ItemProperty -Name "(Default)" -Value "" | |
Write-Host " The Registry Key Value Changed Sucessfully. " -foregroundcolor green | |
} | |
} | |
else { | |
Write-Host " Creating Registry Key.. " -foregroundcolor Gray | |
New-itemProperty -path $Path -Name $keyname -value $SetValue -force | |
Get-ChildItem -Path "HKCU:\AppEvents\Schemes\Apps" | | |
Get-ChildItem | | |
Get-ChildItem | | |
Where-Object { $_.PSChildName -eq ".Current" } | | |
Set-ItemProperty -Name "(Default)" -Value "" | |
Write-Host " The Registry Key Created Sucessfully. " -foregroundcolor green | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment