I created this script to send a message to all of our managed systems if there are problems and email is not working.

Here is the overview of the files what you need.

The computer.txt is the list of all hostnames where you want to send message.

PsExec you can download at Microsoft.

readme.txt is a short manual how to use it for other people

The startmij.cmd file below you can only run when the files are local on the system with UAC enabled and tested only with Windows 7. And you need to have local admin rights on all of the domain computers.

@echo off
REM ########################################################
REM ## Created by Daag van der Meer                     ##
REM ########################################################

REM ###########################################################
REM ## CHECKING FOR ADMIN                                    ##
REM ###########################################################
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    exit /B
:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"
REM ###########################################################
REM ## End Checking for ADMIN                                ##
REM ###########################################################

:START
cls
Echo ###########################################################
Echo ## Hiermee stuur je een popupmelding naar elke pc die    ##
echo ## in computers.txt vermeld staat.                       ##
echo ###########################################################
echo.
Echo Voer de tekst in wat je wilt versturen naar alle pc's.
echo.
set /p text=Je tekst:
cls
set /p tijd=Hoeveel seconden moet dit bericht blijven staan:
cls
echo Uw ingevoerde tekst:
echo %text%
echo.
echo Tijdweergave van dit bericht in secondes
echo %tijd%
echo.
set/p KEUZE=Klopt dit? (J)a, N(ee)
if "%KEUZE%"=="j" goto STUURMSG
if "%KEUZE%"=="J" goto STUURMSG
if "%KEUZE%"=="n" goto START
if "%KEUZE%"=="N" goto START

:STUURMSG
@echo on
PsExec.exe -n 20 @computers.txt msg * /time:%tijd% %text%

Leave a Reply

Your email address will not be published. Required fields are marked *