93

This feature seems to have been added in PowerShell version 5.1, as I don't find it on my laptop still running 5.0.

When pressing Backspace in PowerShell, it will emit a 'beep' sound if there is no (more) text to delete. This is quite annoying if you accidentally hold down the key too long, as the sound will keep going for a short while after you release it.

I found this Super User question which suggests to disable the Beep service, which does work, but I would like to still be able to use beeps in scripts.

How do I disable the "beep on backspace" sound without disabling beeps completely?

5

3 Answers 3

134

The beep is provided by the PSReadline module, which shipped with Windows 10. You need to change the PSReadline option to disable the bell:

Set-PSReadlineOption -BellStyle None

If you want this change for all future PowerShell sessions, then you need to add this command to your PowerShell profile. For example, to set the option for "Current User, Current Host" ($Profile):

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
if (!(Test-Path -Path "$Profile")) {New-Item -ItemType File -Path "$Profile" -Force}
Add-Content -Value "Set-PSReadlineOption -BellStyle None" -Path "$Profile"

The first line allows your profile run a startup script when PowerShell opens (About Execution Policies). The second line tests to see if you already have a startup script defined for "Current User, Current Host". The third line adds the bell option to your startup script.

2
  • 5
    @Odys no - that's the same way you'd have to do it in Bash/ZSH or any Unix shell too. Jul 16, 2017 at 5:30
  • this requires running scripts; disabled by default (win10)
    – Alex
    Oct 25, 2021 at 15:59
21

A more permanent solution that extends @PetSerAl's answer:

  1. Run PowerShell as administrator.
  2. Execute: set-executionpolicy remotesigned. This will allow PowerShell scripts to run on your computer. If you are not sure on what that is do not continue.
  3. Go to C:\Windows\System32\WindowsPowerShell\v1.0 if you are on Windows 10.
  4. Create a file named Microsoft.PowerShell_profile.ps1.
  5. Edit that file and add Set-PSReadlineOption -BellStyle None.
  6. Open a new PowerShell console and you should not hear the beep any more.

All (new) PowerShell consoles for all users on your computer are now silent.

This answer is for Windows 10.  For other versions of Windows, the folder might differ.

2
  • 1
    Set-ExecutionPolicy may require elevated permissions, so if you want to change this setting for your own user only, you can use it with -Scope CurrentUser argument. Feb 27, 2017 at 11:49
  • @ the down-voter, care to explain?
    – Odys
    Feb 20, 2021 at 10:08
0

An adaptation of @Odys' answer using the Bash shell on the Windows Subsystem for Linux (assuming you have it enabled).

1 Open up a command prompt as an administrator, and run

set-executionpolicy remotesigned

2 Type bash to start the bash shell

3 Change to the proper directory

cd /mnt/c/Windows/System32/WindowsPowerShell/v1.0 

4 Make a file named "Microsoft.Powershell_profile.ps1" and write "Set-PSReadlineOption -BellStyle None" to it

echo "Set-PSReadlineOption -BellStyle None" >> Microsoft.Powershell_profile.ps1
3
  • I can't add a file under the given path, which is no surprise because the access rights to the folder don't include write. I tried to modify access rights, but no luck. Did you face a problem like this?
    – lulijeta
    Oct 4, 2018 at 9:20
  • try sudo chmod 644 ./Microsoft.Powershell_profile.ps1 to give yourself privileges. I don't remember my root password, so I can't confirm this works. Oct 4, 2018 at 9:40
  • 1
    Thank you but chmod can only attempt to change the files access permissions only if the file exists. My problem is that I can't create Microsoft.Powershell_profile.ps1 under the folder v1.0. v1.0 (folder) lacks the access right to write on it, therefore I can't create a file under that folder. I tried to change the access rights of v1.0, but apparently chmod has some issues with subsystem. How did you manage to create a file under v1.0?
    – lulijeta
    Oct 4, 2018 at 10:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .