批量cmd中弹出消息

时间:2014-01-22 00:50:20

标签: vbscript popup cmd message

echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
del %tmp%\tmp.vbs

echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
wscript %tmp%\tmp.vbs
del %tmp%\tmp.vbs

我在其他帖子中找到了这些,但是如何在文本上创建多行呢?

2 个答案:

答案 0 :(得分:3)

像这样:

echo msgbox Replace("Hey!\nHere is a message!", "\n", vbLf) > %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
del %tmp%\tmp.vbs

答案 1 :(得分:0)

不像Ekkehard那么短,而是在一个混合文件中 msgbox的正常返回码减1,为零 - 命中止将返回1,因此中止调用。

<!-- : 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>

请勿更改第一行和---- Begin wsf script --->

之后