You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在批处理文件中添加警告消息框?尝试VBWarning等命令无效

批处理中实现警告样式消息框的正确方法

你之前尝试的VBWarning、VBWarningQuery都不是VBScript里MsgBox函数的有效内置常量,所以才会失效。要实现带警告图标的是/否消息框,应该用VBExclamation这个常量,它对应警告图标样式。

把你代码里的"VBYesNo+VBQuestion"替换成"VBYesNo+VBExclamation"即可,修改后的完整代码如下:

@echo off

call :MsgBox "Are you Sure you want to uninstall? You might accidentally uninstall like: Uninstall Save Files, Batch Files, Folders, and Files. Are you REALLY SURE You want to do this?"  "VBYesNo+VBExclamation" "You REALLY Sure?"
if errorlevel 7 (
    taskkill /f /im cmd.exe
) else if errorlevel 6 (
    start uninstall.bat
)
exit /b

:MsgBox prompt type title
setlocal enableextensions
set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"
>"%tempFile%" echo(WScript.Quit msgBox("%~1",%~2,"%~3") & cscript //nologo //e:vbscript "%tempFile%"
set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul
endlocal & exit /b %exitCode%

补充说明:VBScript MsgBox的常用样式常量对应关系:

  • VBYesNo:4(显示“是”和“否”两个按钮)
  • VBExclamation:48(显示黄色警告图标)
  • VBQuestion:32(显示问号图标)
    这些常量可以直接用加号组合,VBScript会自动计算对应的数值总和。

内容的提问来源于stack exchange,提问作者Gboy The Gamer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 09:45:45