Play default beep in Win 10 batch
Moderator: DosItHelp
Play default beep in Win 10 batch
I have a test.bat file with only
Echo ^G
Running the file in a command prompt plays the beep but not if I run it via a desktop shortcut.
I guess I need some additional commands for Win10. Any help is appreciated.
Thanks
Echo ^G
Running the file in a command prompt plays the beep but not if I run it via a desktop shortcut.
I guess I need some additional commands for Win10. Any help is appreciated.
Thanks
Re: Play default beep in Win 10 batch
Unfortunately I cannot test out the new features of Windows 10 console. But you could just use the old fashion way of using the Beep.
viewtopic.php?t=5860
viewtopic.php?t=5860
Re: Play default beep in Win 10 batch
I couldn't get the script to work this way on my win 10:dosnovice wrote:I have a test.bat file with only
Echo ^G
Running the file in a command prompt plays the beep
Have you changed any cmd property?
penpen
Re: Play default beep in Win 10 batch
From a command prompt I wrote
copy con test.bat
echo ^G (i.e. press CTRL G)
press Ctrl Z to end batch file.
Then run test
copy con test.bat
echo ^G (i.e. press CTRL G)
press Ctrl Z to end batch file.
Then run test
Re: Play default beep in Win 10 batch
Then the content is not:
The "^G" is just a cmd.exe replacement string for the control sequence CTRL+G:
Although easy to understand, you should have mention why you've written it this way in your OP.
I've discarded this ctrl sequence within the file, because no text editor will show it this way.
But most probable it will be shown as an empty sqare, or a question mark.
The reason why you don't hear anything, when running this bat via shortcut is simple:
The console window starts a task, that plays the sound, but there is not enough time to hear the sound,
because the console window closes immediately after it has displayed the glyphs (killing all subtasks).
Use something like (where BEL is the bell character 0x07):
penpen
Edit: Corrected "most possible" to "most probable".
Edit 2: Corrected a flaw.
Code: Select all
echo ^G
Although easy to understand, you should have mention why you've written it this way in your OP.
I've discarded this ctrl sequence within the file, because no text editor will show it this way.
But most probable it will be shown as an empty sqare, or a question mark.
The reason why you don't hear anything, when running this bat via shortcut is simple:
The console window starts a task, that plays the sound, but there is not enough time to hear the sound,
because the console window closes immediately after it has displayed the glyphs (killing all subtasks).
Use something like (where BEL is the bell character 0x07):
Code: Select all
echo BEL
timeout 2
penpen
Edit: Corrected "most possible" to "most probable".
Edit 2: Corrected a flaw.
Last edited by penpen on 25 Jul 2016 15:41, edited 2 times in total.
Re: Play default beep in Win 10 batch
penpen wrote: no text editor will show it this way.
But most possible it will be shown as an empty sqare, or a question mark.
For example, within my particular editor it shows as a large round dot, but a screen print within that editor shows the record like this:
Code: Select all
---------------------------------------------------------------------------------------
000001 Echo
46662022222222222222222222222222222222222222222222222222222222222222222222222222
538F0700000000000000000000000000000000000000000000000000000000000000000000000000
---------------------------------------------------------------------------------------
Here are the important bytes from the above codebox:
Code: Select all
Echo
John A.
Re: Play default beep in Win 10 batch
@thefeduke, and all who mght be interested. (although offtopic, i think)
Just for information:
The different visualizations of that ctrl-character depends on the definition used (sounds abstract).
The "large round dot" is mostly used by old(er) applications using this definition of cp 437, 850, ... (for example under MS-DOS 6.22):
https://de.wikipedia.org/wiki/Codepage_437
Btw: Your "screen print" is looking really strange:
What editor did you use?
Nowadays, this definition of cp 437, 850, ... is in use:
https://msdn.microsoft.com/en-us/goglobal/cc305156
There you see, that ANSI character 0x07 is mapped to U+0007.
The (more or less) funny thing is this is mostly not rendered as defined by unicode.org
(because the the method of truetype fonts, to use the ".notdef" glyph if a character cannot be rendered, is older).
Unicode org has defined to use no glyph because it is a ctrl character (=="invisible" width=height=0; but it still is there and could be copied).
If you want to force displaying this character you have to use the REPLACEMENT CHARACTER:
http://unicode.org/cldr/utility/character.jsp?a=0007
But actual use is: Only use this glyph to display errors in stream/coding/... (this is more helpfull, when analyzing streams).
=> When using fonts typically the ".notdef" glyph is used, which is recommended to be a vertical rectangle (== "empty square in the editor ..."), a vertical rectangle containing a question mark, and a vertical rectangle with diagonals.
(The first two glyphs have been implemented for most TTF's i have seen, so: "most probable" ... not the flaw i've first written: "most possible")
But nevertheless the glyph could be any for example a whitespace (== "blank" - i assume).
Might be confusing on a first look, but is pretty usefull.
(I also recommend not to use ctrl characters in forums, better use the old shortcuts: NUL, SOH, ... BEL, ... .
penpen
Just for information:
The different visualizations of that ctrl-character depends on the definition used (sounds abstract).
The "large round dot" is mostly used by old(er) applications using this definition of cp 437, 850, ... (for example under MS-DOS 6.22):
https://de.wikipedia.org/wiki/Codepage_437
Btw: Your "screen print" is looking really strange:
What editor did you use?
Nowadays, this definition of cp 437, 850, ... is in use:
https://msdn.microsoft.com/en-us/goglobal/cc305156
There you see, that ANSI character 0x07 is mapped to U+0007.
The (more or less) funny thing is this is mostly not rendered as defined by unicode.org
(because the the method of truetype fonts, to use the ".notdef" glyph if a character cannot be rendered, is older).
Unicode org has defined to use no glyph because it is a ctrl character (=="invisible" width=height=0; but it still is there and could be copied).
If you want to force displaying this character you have to use the REPLACEMENT CHARACTER:
http://unicode.org/cldr/utility/character.jsp?a=0007
But actual use is: Only use this glyph to display errors in stream/coding/... (this is more helpfull, when analyzing streams).
=> When using fonts typically the ".notdef" glyph is used, which is recommended to be a vertical rectangle (== "empty square in the editor ..."), a vertical rectangle containing a question mark, and a vertical rectangle with diagonals.
(The first two glyphs have been implemented for most TTF's i have seen, so: "most probable" ... not the flaw i've first written: "most possible")
But nevertheless the glyph could be any for example a whitespace (== "blank" - i assume).
Might be confusing on a first look, but is pretty usefull.
(I also recommend not to use ctrl characters in forums, better use the old shortcuts: NUL, SOH, ... BEL, ... .
penpen
Re: Play default beep in Win 10 batch
dosnovice wrote:I have a test.bat file with only
Echo ^G
Running the file in a command prompt plays the beep but not if I run it via a desktop shortcut.
I guess I need some additional commands for Win10. Any help is appreciated.
Thanks
Control G was reliable in the MSDOS days and an alternate method today is scripting a media player like VLC to play an MP3 file with the sound you want inside.
Windows has many sounds in the Media folder in the Windows directory that you can choose from.
Re: Play default beep in Win 10 batch
Thank you for the catalog of background sources. So, BEL seems to be an example of an accepted shorthand from these tables in this world of what you don't see is what you get. Aside: I remember going "online" with a CMC Selectric typewriter, telephone and 50b acoustic coupler. Now I can visualize a Magnetic Card full of characters and these codes that caused mechanical movement in the typewriter.penpen wrote:Use something like (where BEL is the bell character 0x07):
I used a line editor, called SPFlite http://spflite.com, that can toggle a plain or hex display. The application copies the displayed text (not a screen image) to the clipboard, from which I selected one line for my post.penpen wrote:Btw: Your "screen print" is looking really strange:
What editor did you use?
John A.
Re: Play default beep in Win 10 batch
thefeduke wrote:]I used a line editor, called SPFlite http://spflite.com, that can toggle a plain or hex display. The application copies the displayed text (not a screen image) to the clipboard, from which I selected one line for my post.
John A.
SWEET. Did not know this existed. Been a mainframe user for 20 years and always wanted some of the features that most Windows text editors did not have.
Re: Play default beep in Win 10 batch
Yes, and no.thefeduke wrote:So, BEL seems to be an example of an accepted shorthand from these tables in this world of what you don't see is what you get.
If writing in a (non source code) text, or in a source code comment, then BEL is a valid (and one of the well known) name for this character.
But in source code (no comment) it is not valid:
You have to add the information, that this should be interpreted as the bell character via additional text (or comment) like 'where BEL is the bell character 0x07', or 'let "BEL" be the BEL', ....
If there is no such information, then BEL is just the sequence of characters 'B', 'E', 'L'.
So you could also use "echo ^G", but you have to add the information, that "^G" is the BEL (bell character, 0x07, ...).
If there is no such information, then "^G" is just a sequence of the characters '^', 'G'.
Information could also be well known in different contexts, so if typing ^G into the console window of cmd.exe, then it might be the bell character;
see my second post, why i've assumed, that this is not the case (this time, so i've assumed '^'; 'G').
It may sound like i am very particular about this, but here a new behaviour/feature is addressed here.
One had to guess which one of these:
- new cmd.exe behavior interpreting "^G" as BEL
- treat shortcut calls of bat files in a different way, then calling bat from within command line context,
- playing ping in another way
- ...
In addition dosnovice understood that one have guessed wrong and added the missing detail,
so i think this my sight is not too unusual.
Thanks, it sounds interesting, so i'll test it, too.thefeduke wrote:SPFlite http://spflite.com
penpen
Re: Play default beep in Win 10 batch
Code: Select all
rundll32.exe cmdext.dll,MessageBeepStub
rundll32 user32.dll,MessageBeep
but the sound sounds different from echo ^G (but I'm not sure)