` is PowerShell's escape character, which modifies the meaning of the character after it. means the same thing) to Write-Host, which displays something to the screen (or triggers the Windows notification sound in the case of BEL).Īn alternative method in PowerShell is to use the escape sequence for BEL, rather than inserting a literal BEL character with Ctrl + G: echo `a In the interest of completeness, here's the PowerShell method: echo ^G (note that PlaySync is used in the second example since the standard asynchronous play would be interrupted by the PowerShell process closing when launched like this)Īnd if you wanted to play only the first, say, 5 seconds of the sound: powershell -c (New-Object Media.SoundPlayer 'C:\Windows\Media\notify.wav').Play() Start-Sleep -s 5 Exit Ī beep can be easily accomplished in the normal command line with echo ^G (where ^G represents BEL, ASCII character 7, inserted with Ctrl + G), as described in other answers. If you want, you can run this from the normal command line: powershell -c (New-Object Media.SoundPlayer 'C:\Windows\Media\notify.wav').PlaySync() (New-Object Media.SoundPlayer 'C:\WINDOWS\Media\notify.wav').Play() NET class, which can be used to play a wave file.
PowerShell is included with Windows Vista and later, and can be downloaded from Microsoft for older versions. You can do this natively with PowerShell.