Windowsレジストリ経由でWindowsのサウンドスキームを変更する

Windowsレジストリ経由でWindowsのサウンドスキームを変更する

レジストリを編集して、既存のユーザーのサウンド スキームを「サウンドなし」に変更するにはどうすればよいですか? 新しくインストールした Windows で必要なすべての調整を含む .reg ファイルを作成していますが、サウンド スキームの変更に行き詰まっています。

答え1

スキームの変更は比較的簡単です。ただし、その後に適用する新しいスキームは、もう少し複雑です。

「サウンドなし」スキームには という名前が付けられています.None。 を調べると、これを確認できますHKEY_CURRENT_USER\AppEvents\Schemes\Names

選択されたスキームは でHKEY_CURRENT_USER\AppEvents\Schemes、デフォルトは です.Default。したがって、これを に変更することで、選択されたスキームを設定できます.None

New-ItemProperty -Path HKCU:\AppEvents\Schemes -Name "(Default)" -Value ".None" -Force | Out-Null

これにより、(技術的には)選択したスキームが設定されます。サウンド設定に移動してスキームが選択されていることを確認することで確認できますNo Sounds。ただし、イベントサウンドは引き続き再生されます。これは、選択したスキームがまだ選択されていないためです。適用済み

サウンド スキームを適用するには、次のアクションが適切です。

  • に一致するアプリ イベントごとにHKEY_CURRENT_USER\AppEvents\Schemes\Apps\*\*、新しいスキーム名のサブキーを というサブキーにコピーします.Current

たとえば、サウンドなしスキームを System Exclamation イベントに適用するには、 をコピーしHKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\SystemExclamation\.NoneますHKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\SystemExclamation\.Current

ただし、あなたの場合は、「サウンドなし」のテーマを適用しているので、すべての値をクリアするだけで済みます。これは、1 行で実行できます。

Get-ChildItem -Path "HKCU:\AppEvents\Schemes\Apps" | Get-ChildItem | Get-ChildItem | Where-Object {$_.PSChildName -eq ".Current"} | Set-ItemProperty -Name "(Default)" -Value ""

ステップバイステップ:

  • Get-ChildItem -Path "HKCU:\AppEvents\Schemes\Apps"すべてのアプリを取得します。
  • Get-ChildItemすべてのアプリイベントを取得します。
  • Get-ChildItem各スキームのすべてのアプリ イベント サウンド設定を取得します。
  • Where-Object {$_.PSChildName -eq ".Current"}現在適用されているすべてのアプリ イベント サウンド設定を選択します。
  • Set-ItemProperty -Name "(Default)" -Value ""サウンド設定をクリアします。

もう少し詳しくは:

下のキーはHKEY_CURRENT_USER\AppEvents\Schemes\Appsアプリで、デフォルト値は表示文字列になっているようです。私のシステムでは、.Default("Windows")、Explorer("File Explorer")、sapisvr("Speech Recognition") です。

各アプリ キーの下のキーは、そのアプリのアプリ イベントです。

各アプリ イベント キーの下のキーは、各サウンド スキームで再生されるサウンドです。 は、HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\SystemExclamation\.Noneサウンドなしスキームを使用しているときに Windows のシステム感嘆符で再生されるサウンドであり、 は、HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\SystemExclamation\.DefaultWindows のデフォルト スキームを使用しているときに Windows のシステム感嘆符で再生されるサウンドです。

さらに、.Currentこのレベルには実際に再生されるサウンドのキーがあります。おそらく、UI で新しいスキームを選択すると、各設定が個別に値にコピーされます.Current

答え2

このスクリプトは私が作成したものです。自己責任で使用してください。

if (-Not (Test-Path 'HKCU:\AppEvents\Schemes\Names\.None'))
{ 
    New-Item -Path 'HKCU:\AppEvents\Schemes\Names' -Name '.None'
    New-ItemProperty -Path 'HKCU:\AppEvents\Schemes\Names\.None' -Name '(Default)' -Type 'String' -Value 'No Sounds'
}

Get-ChildItem -Path 'HKCU:\AppEvents\Schemes\Apps\.Default' | Select Name | ForEach-Object {
    $thing = $_.Name -replace "HKEY_CURRENT_USER", "HKCU:"
    $fullnun = "$thing\.None"
    if (-Not (Test-Path $thing))
    {
        New-Item -Path $thing -Name '.None'
        echo "$thing\.None created"
    } else {
        echo "$thing\.None already existed"
    }

    if (Test-Path($fullnun))
    {
        New-ItemProperty -Path $fullnun -Name '(Default)' -Type 'String' -Value ''
    }
}

Set-ItemProperty -Path 'hkcu:\AppEvents\Schemes' -Name "(Default)" -Type "String" -Value ".None"

答え3

サウンドスキームを「サウンドなし」に設定するコードは次のとおりです。

Write-Host " Setting Sound Schemes to 'No Sound' .." -foregroundcolor Gray -backgroundcolor black

$Path = "HKCU:\AppEvents\Schemes"

$Keyname = "(Default)"

$SetValue = ".None"

$TestPath = Test-Path $Path
if (-Not($TestPath -eq $True)) {
   Write-Host " Creating Folder.. " -foregroundcolor Gray -backgroundcolor black
   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 -backgroundcolor black


   }
   else {

       Write-Host " Changing Key Value.. " -foregroundcolor Gray -backgroundcolor black

       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 -backgroundcolor black
   }

}
else {

   Write-Host " Creating Registry Key.. " -foregroundcolor Gray -backgroundcolor black

   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 -backgroundcolor black
}

関連情報