在Windows中,有没有类似于"notify-send"的功能?

6

我想为Windows 8.1 / Windows 10编写一个定期通知的.bat脚本。在Windows 8.1 / Windows 10(cmd)中是否有类似于Linux中的“notify-send”的命令?


在Windows中有一个net send命令,不确定它是否仍然存在... - aschipfl
msg * /server:%computername% "Hello" - Squashman
1
消息 %username% "你好" 会以警报框的形式通知。但是我想将其作为通知。例如 - 当我们收到邮件时,在右上角弹出的那个蓝色东西。 - hvaminion
2个回答

3

编辑

由于Windows更新,此模块现已过时且无法使用。在此转换中提供了一个可行的代码:https://dev59.com/xKzka4cB1Zd3GeqP50S7#51079409


我制作了一个“模块”,您可以将其添加到您的.bat文件中:

:notif
::Syntaxe : call :notif "Titre" "Message"

set type=Information
set "$Titre=%~1"
Set "$Message=%~2"

::You can replace the $Icon value by Information, error, warning and none
Set "$Icon=Information"
for /f "delims=" %%a in ('powershell -c "[reflection.assembly]::loadwithpartialname('System.Windows.Forms');[reflection.assembly]::loadwithpartialname('System.Drawing');$notify = new-object system.windows.forms.notifyicon;$notify.icon = [System.Drawing.SystemIcons]::%$Icon%;$notify.visible = $true;$notify.showballoontip(10,'%$Titre%','%$Message%',[system.windows.forms.tooltipicon]::None)"') do (set $=)

goto:eof

如何使用

这很简单,您可以轻松地在代码中实现并按照您的意愿使用它。第一步是将您在顶部看到的代码复制并粘贴到您的 .bat 文件中。

完成后,您唯一需要做的事情就是在您的 .bat 文件中使用此命令:

call :notif "{The title}" "{The message}"

当它被执行时,它将显示Windows 8/10通知。

警告:正如您所看到的那样,有一些 > "。 模块需要它们才能工作,因此请不要忘记它们。


为什么没有任何通知显示呢? - Kalamalka Kid
@KalamalkaKid 我已经编辑了我的回答。由于Windows更新改变了推送通知的行为,这段代码不再起作用。请在这里查看可用的代码。 - joprocorp

3

在 Windows 平台上,有一个名为 notify-send 的工具。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接