Avi*_*vaT 6 windows notifications batch-file command-prompt push-notification
我想编写一个 .bat 脚本,用于在 windows 8.1/windows 10 中重复通知。windows 8.1/windows 10 (cmd) 中是否有像 linux 中的“notify-send”这样的命令?
编辑
由于 Windows 更新,该模块现已过时并且无法工作。在此转换中提出了工作代码:/sf/answers/3575558661/
我制作了一个“模块”,您可以将其添加到 .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
Run Code Online (Sandbox Code Playgroud)
如何使用
在代码中实现它并根据需要使用它非常简单且容易。您需要执行的第一步是复制并粘贴您可以在 .bat 文件顶部读取的代码。
当它完成后,你唯一可以做的就是在你的 .bat 文件中使用这个东西:
call :notif "{The title}" "{The message}"
Run Code Online (Sandbox Code Playgroud)
当它被执行时,它会显示一个 Windows 8/10 通知。
警告:如您所见,有一些 > "。模块需要它们才能工作,所以不要忘记它们。