我想为Windows 8.1 / Windows 10编写一个定期通知的.bat脚本。在Windows 8.1 / Windows 10(cmd)中是否有类似于Linux中的“notify-send”的命令?
我想为Windows 8.1 / Windows 10编写一个定期通知的.bat脚本。在Windows 8.1 / Windows 10(cmd)中是否有类似于Linux中的“notify-send”的命令?
编辑
由于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通知。
警告:正如您所看到的那样,有一些 > "。 模块需要它们才能工作,因此请不要忘记它们。
net send
命令,不确定它是否仍然存在... - aschipflmsg * /server:%computername% "Hello"
- Squashman