【问题标题】:what is the "notify-send" equivalent for windows ?windows 的“通知发送”等价物是什么?
【发布时间】:2016-09-16 16:11:00
【问题描述】:

我想为 windows 8.1/windows 10 中的重复通知编写一个 .bat 脚本。 windows 8.1/windows 10 (cmd) 中是否有类似 linux 中的“notify-send”的命令?

【问题讨论】:

  • Windows 中有一个net send 命令 -- 不确定它是否仍然存在...
  • msg * /server:%computername% "Hello"
  • msg %username% "hello" 将通知作为警报框提供。我想要什么作为通知。例如 - 当我们收到邮件时,右上角的那个蓝色的东西会弹出

标签: windows batch-file push-notification notifications command-prompt


【解决方案1】:

编辑

由于 Windows 更新,此模块现已过时且无法运行。在此转换中提出了一个工作代码:https://stackoverflow.com/a/51079409/8522619


我制作了一个“模块”,您可以将其添加到 .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 通知。

警告: 如您所见,有一些 > "。模块需要它们才能工作,所以不要忘记它们。

【讨论】:

  • 为什么不显示任何通知。 ?
  • @KalamalkaKid 我已经编辑了我的答案。由于 Windows 更新更改了推送通知的行为,此代码不再有效。请查看工作代码here
【解决方案2】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-23
    • 2010-11-15
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-11
    相关资源
    最近更新 更多