如何在批处理脚本中创建弹出消息?

时间:2022-11-20 10:42:46

I need to know how to make popup messages in batch scripts without using VBScript or KiXtart or any other external scripting/programming language. I have zero clue about this... had no starting point even. I am aware of NET SEND but the Messenger service is disabled in my current environment.

我需要知道如何在批处理脚本中创建弹出消息,而不使用VBScript或KiXtart或任何其他外部脚本/编程语言。我对此一无所知……甚至没有起点。我知道网络发送,但是在我当前的环境中,信使服务是禁用的。

10 个解决方案

#1


27  

With regard to LittleBobbyTable's answer - NET SEND does not work on Vista or Windows 7. It has been replaced by MSG.EXE

对于LittleBobbyTable的回答,NET SEND不能在Vista或Windows 7上运行。取而代之的是MSG.EXE

There is a crude solution that works on all versions of Windows - A crude popup message can be sent by STARTing a new cmd.exe window that closes once a key is pressed.

有一种基本的解决方案适用于所有版本的Windows——通过启动新的cmd可以发送一个基本的弹出消息。当按下一个键时关闭的exe窗口。

start "" cmd /c "echo Hello world!&echo(&pause"

If you want your script to pause until the message box is dismissed, then you can add the /WAIT option.

如果您希望您的脚本暂停,直到取消消息框,那么您可以添加/WAIT选项。

start "" /wait cmd /c "echo Hello world!&echo(&pause"

#2


39  

msg * "Enter Your Message"

Does this help ?

这有帮助吗?

#3


19  

You can take advantage of CSCRIPT.EXE or WSCRIPT.EXE (which have been present in every version of Windows since, I believe, Windows 95) like this:

您可以利用CSCRIPT。EXE或WSCRIPT。EXE(我相信从Windows 95开始,它就出现在所有版本的Windows中)就像这样:

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

You could also choose the more customizeable PopUp command. This example gives you a 10 second window to click OK, before timing out:

您还可以选择更可定制的弹出命令。这个例子给了你一个10秒的窗口来点击OK,然后退出:

echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp.vbs
echo WScript.Quit (WshShell.Popup( "You have 10 seconds to Click 'OK'." ,10 ,"Click OK", 0)) >> %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
if %errorlevel%==1 (
  echo You Clicked OK
) else (
  echo The Message timed out.
)
del %tmp%\tmp.vbs

In their above context, both cscript and wscript will act the same. When called from a batch file, bot cscript and wscript will pause the batch file until they finish their script, then allow the file to continue.

在上面的上下文中,cscript和wscript都将执行相同的操作。当从批处理文件中调用时,bot cscript和wscript将暂停批处理文件,直到它们完成脚本,然后允许文件继续。

When called manually from the command prompt, cscript will not return control to the command prompt until it is finished, while wscript will create a seprate thread for the execution of it's script, returning control to the command prompt even before it's script has finished.

当从命令提示中手动调用时,cscript将不会将控制返回到命令提示符,直到它完成,而wscript将创建一个seprate线程来执行它的脚本,在脚本完成之前将控制返回到命令提示符。

Other methods discussed in this thread do not cause the execution of batch files to pause while waiting for the message to be clicked on. Your selection will be dictated by your needs.

此线程中讨论的其他方法不会导致批处理文件的执行在等待单击消息时暂停。您的选择将取决于您的需要。

Note: Using this method, multiple button and icon configurations are available to cover various yes/no/cancel/abort/retry queries to the user: https://technet.microsoft.com/en-us/library/ee156593.aspx

注意:使用此方法,可以使用多个按钮和图标配置来覆盖对用户的各种yes/no/cancel/abort/重试查询:https://technet.microsoft.com/en-us/library/ee156593.aspx

如何在批处理脚本中创建弹出消息?

#4


16  

Few more ways (in all of them the script waits for button pressing unlike msg.exe).

几乎没有其他的方法(与msg.exe不同,脚本在所有这些方法中都等待按钮按下)。

1) The geekiest and hackiest - it uses the IEXPRESS to create small exe that will create a pop-up with a single button (it can create two more types of pop-up messages).Works on EVERY windows from XP and above:

1) geekiest和hackest——它使用IEXPRESS创建一个小型exe,该exe将使用一个按钮创建一个弹出窗口(它可以创建另外两种类型的弹出消息)。适用于从XP或以上的所有windows:

;@echo off
;setlocal

;set ppopup_executable=popupe.exe
;set "message2=click OK to continue"
;
;del /q /f %tmp%\yes >nul 2>&1
;
;copy /y "%~f0" "%temp%\popup.sed" >nul 2>&1

;(echo(FinishMessage=%message2%)>>"%temp%\popup.sed";
;(echo(TargetName=%cd%\%ppopup_executable%)>>"%temp%\popup.sed";
;(echo(FriendlyName=%message1_title%)>>"%temp%\popup.sed"
;
;iexpress /n /q /m %temp%\popup.sed
;%ppopup_executable%
;rem del /q /f %ppopup_executable% >nul 2>&1

;pause

;endlocal
;exit /b 0


[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=1
HideExtractAnimation=1
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[SourceFiles]
SourceFiles0=C:\Windows\System32\
[SourceFiles0]
%FILE0%=


[Strings]
AppLaunched=subst.exe
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="subst.exe"
DisplayLicense=
InstallPrompt=

2) Using MSHTA. Also works on every windows machine from XP and above (despite yhe OP do not wants "external" languages the jsvascript here is minimized).Should be saved as .bat:

2)使用MSHTA。也适用于从XP或以上的所有windows机器(尽管yhe OP不需要“外部”语言,这里的jsvascript在这里是最小化的)。应该被保存为。bat:

@if (true == false) @end /*!
@echo off
mshta "about:<script src='file://%~f0'></script><script>close()</script>" %*
goto :EOF */

alert("Hello, world!");

or in one line:

或在一行:

mshta "about:<script>alert('Hello, world!');close()</script>"

or

mshta "javascript:alert('message');close()"

or

mshta.exe vbscript:Execute("msgbox ""message"",0,""title"":close")

3) Here's parametrized .bat/jscript hybrid (should be saved as bat) .It again uses jscript despite the OP request but as it is a bat it can be called as a bat file without worries.It uses POPUP which allows a little bit more control than the more populae MSGBOX.It uses WSH ,but not MSHTA like in the example above.

3)这是参数化的.bat/jscript混合文件(应该保存为bat),尽管有OP请求,它仍然使用jscript,但作为bat,它可以被作为bat文件调用,不用担心。它使用的弹出窗口允许比更流行的MSGBOX多一点的控制。它使用WSH,但不像上面的示例那样使用MSHTA。

 @if (@x)==(@y) @end /***** jscript comment ******
     @echo off

     cscript //E:JScript //nologo "%~f0" "%~nx0" %*
     exit /b 0

 @if (@x)==(@y) @end ******  end comment *********/


var wshShell = WScript.CreateObject("WScript.Shell");
var args=WScript.Arguments;
var title=args.Item(0);

var timeout=-1;
var pressed_message="button pressed";
var timeout_message="timedout";
var message="";

function printHelp() {
    WScript.Echo(title + "[-title Title] [-timeout m] [-tom \"Time-out message\"] [-pbm \"Pressed button message\"]  [-message \"pop-up message\"]");
}

if (WScript.Arguments.Length==1){
    runPopup();
    WScript.Quit(0);
}

if (args.Item(1).toLowerCase() == "-help" ||  args.Item(1).toLowerCase() == "-h" ) {
    printHelp();
    WScript.Quit(0);
}

if (WScript.Arguments.Length % 2 == 0 ) {
    WScript.Echo("Illegal arguments ");
    printHelp();
    WScript.Quit(1);
}

for (var arg = 1 ; arg<args.Length;arg=arg+2) {

    if (args.Item(arg).toLowerCase() == "-title") {
        title = args.Item(arg+1);
    }

    if (args.Item(arg).toLowerCase() == "-timeout") {
        timeout = parseInt(args.Item(arg+1));
        if (isNaN(timeout)) {
            timeout=-1;
        }
    }

    if (args.Item(arg).toLowerCase() == "-tom") {
        timeout_message = args.Item(arg+1);
    }

    if (args.Item(arg).toLowerCase() == "-pbm") {
        pressed_message = args.Item(arg+1);
    }

    if (args.Item(arg).toLowerCase() == "-message") {
        message = args.Item(arg+1);
    }
}

function runPopup(){
    var btn = wshShell.Popup(message, timeout, title, 0x0 + 0x10);

    switch(btn) {
        // button pressed.
        case 1:
            WScript.Echo(pressed_message);
            break;

        // Timed out.
        case -1:
           WScript.Echo(timeout_message);
           break;
    }
}

runPopup();

4) and one jscript.net/.bat hybrid (should be saved as .bat) .This time it uses .NET and compiles a small .exe file that could be deleted:

4)和一个jscript.net/.bat混合文件(应该保存为.bat),这次它使用。net编译一个小的。exe文件,可以删除:

@if (@X)==(@Y) @end /****** silent jscript comment ******

@echo off
::::::::::::::::::::::::::::::::::::
:::       compile the script    ::::
::::::::::::::::::::::::::::::::::::
setlocal


::if exist "%~n0.exe" goto :skip_compilation

:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
    if exist "%%v\jsc.exe" (
        rem :: the javascript.net compiler
        set "jsc=%%~dpsnfxv\jsc.exe"
        goto :break_loop
    )
)
echo jsc.exe not found && exit /b 0
:break_loop



call %jsc% /nologo /out:"%~n0.exe" "%~f0" 
::::::::::::::::::::::::::::::::::::
:::       end of compilation    ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation

::
::::::::::
"%~n0.exe" %*
::::::::
::
endlocal
exit /b 0

****** end of jscript comment ******/

import System;
import System.WIndows;
import System.Windows.Forms

var arguments:String[] = Environment.GetCommandLineArgs();
MessageBox.Show(arguments[1],arguments[0]);

5) and at the end one single call to powershell that creates a pop-up (can be called from command line or from batch if powershell is installed):

5)最后对powershell进行一次调用,创建一个弹出窗口(如果安装了powershell,可以从命令行或批处理调用):

powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show("""Hello World""", """My PopUp Message Box""")

6) Though msg solution is already post as answer here's a better way to be used:

虽然msg解决方案已经被贴上了答案,但这里有一个更好的使用方法:

msg * /self /w "hello world"

/self is a not documented switch that will force msg to send the message only to the current user.

/self是一个没有文档记录的开关,它将迫使msg只向当前用户发送消息。

#5


4  

msg * Hello world

味精* Hello world

works for me..

适合我. .

#6


0  

Your best bet is to use NET SEND as documented on Rob van der Woude's site.

你最好的选择是使用netsend,正如Rob van der Woude网站上所记载的那样。

Otherwise, you'll need to use an external scripting program. Batch files are really intended to send messages via ECHO.

否则,您将需要使用外部脚本程序。批处理文件实际上是打算通过ECHO发送消息。

#7


0  

This is very simple beacuse i have created a couple lines of code that will do this for you

这非常简单,因为我已经创建了几行代码,可以为您实现这一点

So set a variable as msg and then use this code. it popup in a VBS message box.

因此,将变量设置为msg,然后使用此代码。它在VBS消息框中弹出。

CODE:

代码:

@echo off
echo %msg% >vbs.txt
copy vbs.txt vbs.vbs
del vbs.txt
start vbs.vbs
timeout /t 1
del vbs.vbs
cls

This is just something i came up with it should work for most of your message needs and it also works with Spaces unlike some batch scripts

这只是我想到的东西,它应该适用于您的大多数消息需求,而且它也适用于与某些批处理脚本不同的空间

#8


0  

It's easy to make a message, here's how:

这很容易传达一个信息,以下是如何做到的:

First open notpad and type:

首先打开notpad,类型:

msg "Message",0,"Title"

and save it as Message.vbs.

并将其保存为Message.vbs。

Now in your batch file type:

现在在您的批处理文件类型:

Message.vbs %*

#9


0  

msg * message goes here

That method is very simple and easy and should work in any batch file i believe. The only "downside" to this method is that it can only show 1 message at once, if there is more than one message it will show each one after the other depending on the order you put them inside the code. Also make sure there is a different looping or continuous operator in your batch file or it will close automatically and only this message will appear. If you need a "quiet" background looping opperator, heres one:

该方法非常简单,而且应该适用于任何批处理文件。这种方法唯一的“缺点”是,它只能同时显示一条消息,如果有不止一条消息,它将根据您将它们放入代码中的顺序显示每个消息。还要确保批处理文件中有不同的循环或连续操作符,否则它将自动关闭,只会出现此消息。如果你需要一个“安静”的后台循环操作器,这里有一个:

pause >nul

That should keep it running but then it will close after a button is pressed.

这应该会让它继续运行,但是当按下一个按钮后它就会关闭。

Also to keep all the commands "quiet" when running, so they just run and dont display that they were typed into the file, just put the following line at the beginning of the batch file:

同时,为了让所有的命令在运行时保持“安静”,所以它们只会运行,不会显示它们被输入到文件中,只需在批处理文件的开头写上以下一行:

@echo off

I hope all these tips helped!

我希望所有这些建议都有帮助!

#10


0  

@echo off
title message

echo what's the password?
set/p "pass=>"

if not %pass% == password goto fail
msg *correct: Correct password!!!
goto end

:fail
msg *wrong: Wrong password!!!

:end

#1


27  

With regard to LittleBobbyTable's answer - NET SEND does not work on Vista or Windows 7. It has been replaced by MSG.EXE

对于LittleBobbyTable的回答,NET SEND不能在Vista或Windows 7上运行。取而代之的是MSG.EXE

There is a crude solution that works on all versions of Windows - A crude popup message can be sent by STARTing a new cmd.exe window that closes once a key is pressed.

有一种基本的解决方案适用于所有版本的Windows——通过启动新的cmd可以发送一个基本的弹出消息。当按下一个键时关闭的exe窗口。

start "" cmd /c "echo Hello world!&echo(&pause"

If you want your script to pause until the message box is dismissed, then you can add the /WAIT option.

如果您希望您的脚本暂停,直到取消消息框,那么您可以添加/WAIT选项。

start "" /wait cmd /c "echo Hello world!&echo(&pause"

#2


39  

msg * "Enter Your Message"

Does this help ?

这有帮助吗?

#3


19  

You can take advantage of CSCRIPT.EXE or WSCRIPT.EXE (which have been present in every version of Windows since, I believe, Windows 95) like this:

您可以利用CSCRIPT。EXE或WSCRIPT。EXE(我相信从Windows 95开始,它就出现在所有版本的Windows中)就像这样:

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

You could also choose the more customizeable PopUp command. This example gives you a 10 second window to click OK, before timing out:

您还可以选择更可定制的弹出命令。这个例子给了你一个10秒的窗口来点击OK,然后退出:

echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp.vbs
echo WScript.Quit (WshShell.Popup( "You have 10 seconds to Click 'OK'." ,10 ,"Click OK", 0)) >> %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
if %errorlevel%==1 (
  echo You Clicked OK
) else (
  echo The Message timed out.
)
del %tmp%\tmp.vbs

In their above context, both cscript and wscript will act the same. When called from a batch file, bot cscript and wscript will pause the batch file until they finish their script, then allow the file to continue.

在上面的上下文中,cscript和wscript都将执行相同的操作。当从批处理文件中调用时,bot cscript和wscript将暂停批处理文件,直到它们完成脚本,然后允许文件继续。

When called manually from the command prompt, cscript will not return control to the command prompt until it is finished, while wscript will create a seprate thread for the execution of it's script, returning control to the command prompt even before it's script has finished.

当从命令提示中手动调用时,cscript将不会将控制返回到命令提示符,直到它完成,而wscript将创建一个seprate线程来执行它的脚本,在脚本完成之前将控制返回到命令提示符。

Other methods discussed in this thread do not cause the execution of batch files to pause while waiting for the message to be clicked on. Your selection will be dictated by your needs.

此线程中讨论的其他方法不会导致批处理文件的执行在等待单击消息时暂停。您的选择将取决于您的需要。

Note: Using this method, multiple button and icon configurations are available to cover various yes/no/cancel/abort/retry queries to the user: https://technet.microsoft.com/en-us/library/ee156593.aspx

注意:使用此方法,可以使用多个按钮和图标配置来覆盖对用户的各种yes/no/cancel/abort/重试查询:https://technet.microsoft.com/en-us/library/ee156593.aspx

如何在批处理脚本中创建弹出消息?

#4


16  

Few more ways (in all of them the script waits for button pressing unlike msg.exe).

几乎没有其他的方法(与msg.exe不同,脚本在所有这些方法中都等待按钮按下)。

1) The geekiest and hackiest - it uses the IEXPRESS to create small exe that will create a pop-up with a single button (it can create two more types of pop-up messages).Works on EVERY windows from XP and above:

1) geekiest和hackest——它使用IEXPRESS创建一个小型exe,该exe将使用一个按钮创建一个弹出窗口(它可以创建另外两种类型的弹出消息)。适用于从XP或以上的所有windows:

;@echo off
;setlocal

;set ppopup_executable=popupe.exe
;set "message2=click OK to continue"
;
;del /q /f %tmp%\yes >nul 2>&1
;
;copy /y "%~f0" "%temp%\popup.sed" >nul 2>&1

;(echo(FinishMessage=%message2%)>>"%temp%\popup.sed";
;(echo(TargetName=%cd%\%ppopup_executable%)>>"%temp%\popup.sed";
;(echo(FriendlyName=%message1_title%)>>"%temp%\popup.sed"
;
;iexpress /n /q /m %temp%\popup.sed
;%ppopup_executable%
;rem del /q /f %ppopup_executable% >nul 2>&1

;pause

;endlocal
;exit /b 0


[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=1
HideExtractAnimation=1
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[SourceFiles]
SourceFiles0=C:\Windows\System32\
[SourceFiles0]
%FILE0%=


[Strings]
AppLaunched=subst.exe
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="subst.exe"
DisplayLicense=
InstallPrompt=

2) Using MSHTA. Also works on every windows machine from XP and above (despite yhe OP do not wants "external" languages the jsvascript here is minimized).Should be saved as .bat:

2)使用MSHTA。也适用于从XP或以上的所有windows机器(尽管yhe OP不需要“外部”语言,这里的jsvascript在这里是最小化的)。应该被保存为。bat:

@if (true == false) @end /*!
@echo off
mshta "about:<script src='file://%~f0'></script><script>close()</script>" %*
goto :EOF */

alert("Hello, world!");

or in one line:

或在一行:

mshta "about:<script>alert('Hello, world!');close()</script>"

or

mshta "javascript:alert('message');close()"

or

mshta.exe vbscript:Execute("msgbox ""message"",0,""title"":close")

3) Here's parametrized .bat/jscript hybrid (should be saved as bat) .It again uses jscript despite the OP request but as it is a bat it can be called as a bat file without worries.It uses POPUP which allows a little bit more control than the more populae MSGBOX.It uses WSH ,but not MSHTA like in the example above.

3)这是参数化的.bat/jscript混合文件(应该保存为bat),尽管有OP请求,它仍然使用jscript,但作为bat,它可以被作为bat文件调用,不用担心。它使用的弹出窗口允许比更流行的MSGBOX多一点的控制。它使用WSH,但不像上面的示例那样使用MSHTA。

 @if (@x)==(@y) @end /***** jscript comment ******
     @echo off

     cscript //E:JScript //nologo "%~f0" "%~nx0" %*
     exit /b 0

 @if (@x)==(@y) @end ******  end comment *********/


var wshShell = WScript.CreateObject("WScript.Shell");
var args=WScript.Arguments;
var title=args.Item(0);

var timeout=-1;
var pressed_message="button pressed";
var timeout_message="timedout";
var message="";

function printHelp() {
    WScript.Echo(title + "[-title Title] [-timeout m] [-tom \"Time-out message\"] [-pbm \"Pressed button message\"]  [-message \"pop-up message\"]");
}

if (WScript.Arguments.Length==1){
    runPopup();
    WScript.Quit(0);
}

if (args.Item(1).toLowerCase() == "-help" ||  args.Item(1).toLowerCase() == "-h" ) {
    printHelp();
    WScript.Quit(0);
}

if (WScript.Arguments.Length % 2 == 0 ) {
    WScript.Echo("Illegal arguments ");
    printHelp();
    WScript.Quit(1);
}

for (var arg = 1 ; arg<args.Length;arg=arg+2) {

    if (args.Item(arg).toLowerCase() == "-title") {
        title = args.Item(arg+1);
    }

    if (args.Item(arg).toLowerCase() == "-timeout") {
        timeout = parseInt(args.Item(arg+1));
        if (isNaN(timeout)) {
            timeout=-1;
        }
    }

    if (args.Item(arg).toLowerCase() == "-tom") {
        timeout_message = args.Item(arg+1);
    }

    if (args.Item(arg).toLowerCase() == "-pbm") {
        pressed_message = args.Item(arg+1);
    }

    if (args.Item(arg).toLowerCase() == "-message") {
        message = args.Item(arg+1);
    }
}

function runPopup(){
    var btn = wshShell.Popup(message, timeout, title, 0x0 + 0x10);

    switch(btn) {
        // button pressed.
        case 1:
            WScript.Echo(pressed_message);
            break;

        // Timed out.
        case -1:
           WScript.Echo(timeout_message);
           break;
    }
}

runPopup();

4) and one jscript.net/.bat hybrid (should be saved as .bat) .This time it uses .NET and compiles a small .exe file that could be deleted:

4)和一个jscript.net/.bat混合文件(应该保存为.bat),这次它使用。net编译一个小的。exe文件,可以删除:

@if (@X)==(@Y) @end /****** silent jscript comment ******

@echo off
::::::::::::::::::::::::::::::::::::
:::       compile the script    ::::
::::::::::::::::::::::::::::::::::::
setlocal


::if exist "%~n0.exe" goto :skip_compilation

:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
    if exist "%%v\jsc.exe" (
        rem :: the javascript.net compiler
        set "jsc=%%~dpsnfxv\jsc.exe"
        goto :break_loop
    )
)
echo jsc.exe not found && exit /b 0
:break_loop



call %jsc% /nologo /out:"%~n0.exe" "%~f0" 
::::::::::::::::::::::::::::::::::::
:::       end of compilation    ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation

::
::::::::::
"%~n0.exe" %*
::::::::
::
endlocal
exit /b 0

****** end of jscript comment ******/

import System;
import System.WIndows;
import System.Windows.Forms

var arguments:String[] = Environment.GetCommandLineArgs();
MessageBox.Show(arguments[1],arguments[0]);

5) and at the end one single call to powershell that creates a pop-up (can be called from command line or from batch if powershell is installed):

5)最后对powershell进行一次调用,创建一个弹出窗口(如果安装了powershell,可以从命令行或批处理调用):

powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show("""Hello World""", """My PopUp Message Box""")

6) Though msg solution is already post as answer here's a better way to be used:

虽然msg解决方案已经被贴上了答案,但这里有一个更好的使用方法:

msg * /self /w "hello world"

/self is a not documented switch that will force msg to send the message only to the current user.

/self是一个没有文档记录的开关,它将迫使msg只向当前用户发送消息。

#5


4  

msg * Hello world

味精* Hello world

works for me..

适合我. .

#6


0  

Your best bet is to use NET SEND as documented on Rob van der Woude's site.

你最好的选择是使用netsend,正如Rob van der Woude网站上所记载的那样。

Otherwise, you'll need to use an external scripting program. Batch files are really intended to send messages via ECHO.

否则,您将需要使用外部脚本程序。批处理文件实际上是打算通过ECHO发送消息。

#7


0  

This is very simple beacuse i have created a couple lines of code that will do this for you

这非常简单,因为我已经创建了几行代码,可以为您实现这一点

So set a variable as msg and then use this code. it popup in a VBS message box.

因此,将变量设置为msg,然后使用此代码。它在VBS消息框中弹出。

CODE:

代码:

@echo off
echo %msg% >vbs.txt
copy vbs.txt vbs.vbs
del vbs.txt
start vbs.vbs
timeout /t 1
del vbs.vbs
cls

This is just something i came up with it should work for most of your message needs and it also works with Spaces unlike some batch scripts

这只是我想到的东西,它应该适用于您的大多数消息需求,而且它也适用于与某些批处理脚本不同的空间

#8


0  

It's easy to make a message, here's how:

这很容易传达一个信息,以下是如何做到的:

First open notpad and type:

首先打开notpad,类型:

msg "Message",0,"Title"

and save it as Message.vbs.

并将其保存为Message.vbs。

Now in your batch file type:

现在在您的批处理文件类型:

Message.vbs %*

#9


0  

msg * message goes here

That method is very simple and easy and should work in any batch file i believe. The only "downside" to this method is that it can only show 1 message at once, if there is more than one message it will show each one after the other depending on the order you put them inside the code. Also make sure there is a different looping or continuous operator in your batch file or it will close automatically and only this message will appear. If you need a "quiet" background looping opperator, heres one:

该方法非常简单,而且应该适用于任何批处理文件。这种方法唯一的“缺点”是,它只能同时显示一条消息,如果有不止一条消息,它将根据您将它们放入代码中的顺序显示每个消息。还要确保批处理文件中有不同的循环或连续操作符,否则它将自动关闭,只会出现此消息。如果你需要一个“安静”的后台循环操作器,这里有一个:

pause >nul

That should keep it running but then it will close after a button is pressed.

这应该会让它继续运行,但是当按下一个按钮后它就会关闭。

Also to keep all the commands "quiet" when running, so they just run and dont display that they were typed into the file, just put the following line at the beginning of the batch file:

同时,为了让所有的命令在运行时保持“安静”,所以它们只会运行,不会显示它们被输入到文件中,只需在批处理文件的开头写上以下一行:

@echo off

I hope all these tips helped!

我希望所有这些建议都有帮助!

#10


0  

@echo off
title message

echo what's the password?
set/p "pass=>"

if not %pass% == password goto fail
msg *correct: Correct password!!!
goto end

:fail
msg *wrong: Wrong password!!!

:end