这个脚本对我来说是完美的,但请问如何将消息拆分为2或3行以显示在弹出窗口中?
@echo off
call :MsgBox "Would you like to go to URL?" "VBYesNo+VBQuestion" "Click yes to go to URL"
if errorlevel 7 (
echo NO - don't go to the url
) else if errorlevel 6 (
echo YES - go to the url
start "" "http://www.google.com"
)
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%
答案 0 :(得分:1)
这是一个用以下方法测试的想法:
@echo off
Set "URL=https://www.google.com"
Call :MsgBox "Would you like to go \n to URL : %URL% ? \n YES go to this URL \n or \n NO to quit this script" ^
"VBYesNo+VBQuestion" "Click yes to go to URL"
if errorlevel 7 (
echo NO - don't go to the url
) else if errorlevel 6 (
echo YES - go to the url
start "" "%URL%"
)
exit /b
:MsgBox prompt type title
setlocal enableextensions
set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"
>"%tempFile%" echo(WScript.Quit MsgBox(Replace("%~1","\n",vbcrlf),%~2,"%~3") & cscript //nologo //e:vbscript "%tempFile%"
set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul
endlocal & exit /b %exitCode%
答案 1 :(得分:0)
如果你为你的行代码编码如下:
"Line 1" & vbCrLf & "Line 2" & vbCrLf & "Line 3"
您将得到如下结果:
Line 1
Line 2
Line 3
希望这有帮助。