尝试用这样的choice
东西替换你的命令。
set /p choice="Please enter a choice: "
它需要用户按回车键,但至少它不会发出哔哔声。
如果您真的想以艰难的方式做到这一点并关闭默认声音,我想您会HKCU\AppEvents\Schemes\Apps\.Default\SystemAsterisk\.Current\(Default)
在HKCU\AppEvents\Schemes\Apps\.Default\AppGPFault\.Current\(Default)
.
这是一个简短的概念证明。
@echo off
setlocal
:: stop bleeping service
start /wait %comspec% /Q /C "sc stop beep" >nul 2>&1
:: store current event setting for Asterisk
set loc=HKCU\AppEvents\Schemes\Apps\.Default\SystemAsterisk\.Current
for /f "tokens=3*" %%I in ('reg query %loc%') do (
set asterisk=%%I %%J
)
:: choice with service stopped and Windows Asterisk sound event still active
choice
:: set Windows Asterisk event sound to ""
reg add "%loc%" /v "" /t REG_SZ /d "" /f >NUL
:: choice with asterisk set to ""
choice
:: restore the sound
reg add "%loc%" /v "" /t REG_SZ /d "%asterisk%" /f >NUL
如果这不起作用,请尝试替换SystemAsterisk
为AppGPFault
. 老实说,我无法重现你的症状。停止哔声服务后,我听到了沉默。所以我不完全确定当用户点击空格键并且哔声服务停止时会触发哪个事件。