【问题标题】:Pop up Message in batch cmd批量cmd弹出消息
【发布时间】:2014-01-22 00:50:20
【问题描述】:
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

我在其他线程中找到了这些,但是如何在文本上使其成为多行?

【问题讨论】:

    标签: vbscript popup cmd message


    【解决方案1】:

    像这样:

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

    【讨论】:

      【解决方案2】:

      不像 Ekkehard 那样短,而是在一个混合文件中。
      msgbox 的正常返回码减 1 变为 0 - 点击 abort 将返回 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 ---&gt;之后不要更改

      【讨论】:

        猜你喜欢
        • 2018-10-02
        • 2021-04-24
        • 2016-12-15
        • 2011-10-28
        • 2013-11-15
        • 1970-01-01
        • 1970-01-01
        • 2016-06-14
        • 1970-01-01
        相关资源
        最近更新 更多