How to Play Beep Conditionally?

Asked by At

I want to play a beep sound if a copy operation fails.

copy C:\Amethyst\Original.docx C:\Backup
if %ERRORLEVEL% NEQ 0 (
    echo 
)

The sound always plays.

1 Answers

-1
Community On

(Translated from French)

Hi,
What you ask is not directly feasible with CMD ... but with NIRCMD.exe it is possible !

Download Here

  • 1) Unzip nircmd.zip

  • 2) Move the 3 files (nircmd.exe, nircmdc.exe, nircmd.chm) into C:/Windows/System32

  • +) For more help on NIRCMD, type nircmd.chm in the command prompt

For the beep, there are several solutions:
- nircmd stdbeep will play the default Windows beep
- nircmd beep [Frequency] [Duration] will play a beep with a frequency of [Frequency] Hz for [Duration] milliseconds
- nircmd mediaplay [play time] [audio file] will play [audio file] for [play time] milliseconds

I hope I answered your question

Yassin