This article will discuss how to disable the system sounds via the registry.  I know that the title is change system sounds, but trust me if you can disable the sounds, you can also change them.  For this article, I will change the registry using a batch file.

My customer requirements are:

  1. Disable system sounds
  2. Disable the start up sound 

Once I disabled the sounds, the customer changed the requirement to include setting the sounds scheme, so we will do that also.

Starting with disabling the system sounds, we first need to know that the system sounds are set in the registry in subkeys of HKEY_CURRENT_USER\AppEvents\Schemes\Apps.  The current sound for each item is defined in the default value for a key named “.current”.   So, to change the sound played for any item, we simply need to change the string value stored in the default value for the key named “.current”, further to disable the sound we simply set the value to the empty string (“”).   Since my requirement is to disable all of the system sounds, I need to search for all subkeys named “.current”.

The first thing to do is look for all subkeys of HKEY_CURRENT_USER\AppEvents\Schemes\Apps.   To do that, use reg.exe and query recursively for all subkeys:

    reg query HKCU\AppEvents\Schemes\Apps /s > AppsKeys.txt

which outputs the results to a file that we can process.  To process the subkeys, I will use the following function:

:DisableSystemSounds
    set KeyFile=AppsKeys.txt
    reg query HKCU\AppEvents\Schemes\Apps /s > "%KeyFile%"

    FOR /F %%I in (%KeyFile%) DO (
        if NOT "%%I"=="(Default)"  call :ProcessFoundData "%%I"
    )
    del "%KeyFile%"
 
    goto :EOF

If you look at the output, you will see that it includes both the keys and values.   Luckily for this batch file, the values are all named “(Default)”.  So with that information, I simply exclude all keys named (Default) and process everything else with the ProcessFoundData function:

:ProcessFoundData
    set Key=%~1
    call :KeyExists "%key%\.current"
    IF not ERRORLEVEL 1 (
        reg add "%key%\.current" /t REG_SZ /d "" /f 2>nul >nul
    )

    goto :EOF

ProcessFoundData looks for keys that contain a subkey named “.current” and sets the default value to the empty string.  Simple enough, but it took me several tries to figure out how to determine if the subkey “.current” exists, and the result is the KeyExists function below:

:KeyExists
    REM if the key exists, ERRORLEVEL will be zero
    reg query "%~1" /ve 2>nul >null
    goto :EOF

So, now I have disabled the system sounds, but it turns out that the Windows startup sound is handled differently.  The Windows startup sound can both be disabled and the user can be prevented from changing the setting in the Control Panel.  The following uses reg.exe to turn off the Windows startup sound and disable the user fro changing the setting:

REM  Disable user from enabling the startup sound
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v DisableStartupSound /t REG_DWORD /d 1 /f 2>nul >nul

REM Somehow setting DisableStartupSOund here actually disables the sound (kind of opposite...)
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation /v DisableStartupSound /t REG_DWORD /d 0 /f 2>nul >nul

 

And finally, change the sound scheme to No Sound:

REM Set the sound scheme to No Sound
reg add HKCU\AppEvents\Schemes /t REG_SZ /d ".None" /f 2>nul >nul

To be honest, that isn’t really setting the scheme to No Sound, just the name that is displayed.   If you really want to change the sound scheme the way the Control Panel does, I suspect that you will need to copy the default values from the .None sounds to the .current settings.

Putting this all together, the batch file is:

@echo off


REM  Disable user from enabling the startup sound
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v DisableStartupSound /t REG_DWORD /d 1 /f 2>nul >nul

REM Somehow setting DisableStartupSOund here actually disables the sound (kind of opposite...)
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation /v DisableStartupSound /t REG_DWORD /d 0 /f 2>nul >nul

REM Set the sound scheme to No Sound
reg add HKCU\AppEvents\Schemes /t REG_SZ /d ".None" /f 2>nul >nul


call :DisableSystemSounds


goto :EOF

:DisableSystemSounds
    set KeyFile=AppsKeys.txt
    reg query "HKCU\AppEvents\Schemes\%1" /s > "%KeyFile%"

    FOR /F %%I in (%KeyFile%) DO (
        if NOT "%%I"=="(Default)"  call :ProcessFoundData "%%I"
    )
    del "%KeyFile%"
 
    goto :EOF

:ProcessFoundData
    set Key=%~1
    call :KeyExists "%key%\.current"
    IF ERRORLEVEL 1 (
        echo not found > nul
    ) else (
        rem echo XX %key%\.current
        reg add "%key%\.current" /t REG_SZ /d "" /f 2>nul >nul
        echo .
    )

    goto :EOF

:KeyExists
    REM if the key exists, ERRORLEVEL will be zero
    reg query "%~1" /ve 2>nul >null
    goto :EOF