问题
echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
del %tmp%\tmp.vbs
or
echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
wscript %tmp%\tmp.vbs
del %tmp%\tmp.vbs
I found these in other thread, however how to I make it multiple lines on the text?
回答1:
Like this:
echo msgbox Replace("Hey!\nHere is a message!", "\n", vbLf) > %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
del %tmp%\tmp.vbs
回答2:
Not as short as Ekkehard's but in a single hybrid file.
The normal return code of msgbox is decreased by one to have zero - hitting abort will return one and so abort the call.
<!-- : Begin batch script
@echo off&SETLOCAL EnableDelayedExpansion
echo.
echo Step1: Closing Explorer . . .
echo.
Call :MsgBox "Do you really want to restart the explorer?" "Title" ||(Goto :Abort)
TASKKILL /F /IM explorer.exe
echo.
echo.
echo Step2: Launching Explorer . . .
start explorer.exe
echo.
echo Success: Explorer started.
echo.
echo.
Goto :Eof
:Abort
Echo Aborted with errorlevel !Errorlevel!
Exit /B !Errorlevel!
:MsgBox
for /f "Delims=" %%i in (
'cscript.exe //Nologo "%~f0?.wsf" "%~1" "%~2"'
) do set "Ret=%%i"
Exit /B %Ret%
Goto :Eof
----- Begin wsf script --->
<job><script language="VBScript">
Set oArgs = WScript.Arguments
If oArgs.Count = 2 Then
Ret = MsgBox(oArgs.Item(0),1,oArgs.Item(1))
Wscript.Echo Ret-1
Wscript.Quit (Ret -1)
End if
</script></job>
Don't change the first line and after ---- Begin wsf script --->
来源:https://stackoverflow.com/questions/21272110/pop-up-message-in-batch-cmd