I'm wondering, with batch, vbs or any other built in windows languages, can I make the system beep (like the one when you press a key at startup) go off? I'm not sure if this is possible, but any help would be awesome!
Solved
This is very easy using ctrl+G (which comes up as ^G in cmd).
Simply Type:
Echo ^G
Echo ^G >> beep.txt
Type beep.txt
This can only be used in CMD, unless you redirect the output to a text file (As demonstrated above), where you can then copy it into your batch file or type the file when you want to beep.
Remember in the above code ^G is achieved by key pressing Ctrl + g.
Mona
For VBScript:
WScript.StdOut.Write Chr(7)
For Vista and later you can use forfiles (code sample to use inside a batch file)
forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo 0x07"
In PowerShell this should work:
[char]0x7
Another option, as @Joey pointed out, is the Beep() method:
[Console]::Beep()
[Console]::Beep(500, 300)
You can type
echo ^G
The ^G can be generated by holding "Alt", then typing "7" on the right hand side of your keyboard. Then press enter to hear the beep sound.
Set oShell = CreateObject("Wscript.Shell")
oShell.Run "%comspec% /c echo " & Chr(7),0,false
Set oShell = nothing
No comments:
Post a Comment