Show a popup/message box from a Windows batch file

2019-01-03 07:40发布

Is there a way to display a message box from a batch file (similar to how xmessage can be used from bash-scripts in Linux)?

20条回答
Fickle 薄情
2楼-- · 2019-01-03 08:40

Here's a PowerShell variant that doesn't require loading assemblies prior to creating the window, however it runs noticeably slower (~+50%) than the PowerShell MessageBox command posted here by @npocmaka:

powershell (New-Object -ComObject Wscript.Shell).Popup("""Operation Completed""",0,"""Done""",0x0)

You can change the last "0x0" parameter to display different icons in the dialog, ex. 0x40 shows an "information mark". See Popup Method for reference.

Adapted from the Microsoft TechNet article PowerTip: Use PowerShell to Display Pop-Up Window.

查看更多
做个烂人
3楼-- · 2019-01-03 08:40

You can use Zenity. Zenity allows for the execution of dialog boxes in command-line and shell scripts. More info can also be found on Wikipedia.

It is cross-platform: a Windows installer for Windows can be found here.

查看更多
登录 后发表回答