windowsbatch-filepush-notificationnotificationscommand-prompt

what is the "notify-send" equivalent for windows ?


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 ?


Solution

  • Edit

    This module is now outdated and not working due to a Windows update. A working code has been proposed in this conversation : 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.