6

I want to write a .bat script for recurring notifications in windows 8.1/ windows 10. Is there a command in windows 8.1/windows 10 (cmd) like "notify-send" in linux ?

hvaminion
  • 135
  • 3
  • 10
  • There was a `net send` command in Windows -- not sure whether it still exists... – aschipfl Sep 16 '16 at 16:26
  • `msg * /server:%computername% "Hello"` – Squashman Sep 16 '16 at 17:37
  • 1
    the msg %username% "hello" gives the notification as a alert box . what is i want it as a notification . for example - that blue thing on the top right hand side that pops up when we receive a mail – hvaminion Sep 16 '16 at 17:47

2 Answers2

3

Edit

This module is now outdated and not working due to a Windows update. A working code has been proposed in this conversion : https://stackoverflow.com/a/51079409/8522619


I have made a "module" that you can add in you .bat file :

: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

How to use

It's pretty simple and easy to implement it in your code and use it as you want. The first step you need to make is to copy and paste the code you can read on the top in your .bat file.

When it will done, the only thing you may rest to make is to use in your .bat file this thing :

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

And it's gonna display a windows 8/10 notification when it will be executed.

Warning : as you can see, there are some > ". The module need them to work so don't forget them.

joprocorp
  • 176
  • 10
  • why does this not show any notification. ? – Kalamalka Kid Dec 18 '20 at 11:21
  • @KalamalkaKid I've edited my answer. This code isn't working anymore since a Windows update changing the behaviour of push notifications. Please see a working code [here](https://stackoverflow.com/a/51079409/8522619). – joprocorp Feb 28 '21 at 13:52
3

There is notify-send for Windows.

Polluks
  • 525
  • 2
  • 8
  • 19