85

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?

116

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.

| improve this answer | |
  • 5
    @Odys no - that's the same way you'd have to do it in Bash/ZSH or any Unix shell too. – Tamoghna Chowdhury Jul 16 '17 at 5:30
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.

| improve this answer | |
  • 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. – mehmetseckin Feb 27 '17 at 11:49
1

I filed this Github item against PsReadLine, as I'm not sure this change was intentional - https://github.com/lzybkr/PSReadLine/issues/422

| improve this answer | |
  • 2
    This does not provide an answer to the question and should have been posted as a comment. Non-answers are subject to deletion. – G-Man Says 'Reinstate Monica' Jan 9 '18 at 18:47
1

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
| improve this answer | |
  • 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 '18 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. – Evan Rosica Oct 4 '18 at 9:40
  • 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 '18 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.