Sending Messages to Remote Workstations with a Script
Recently we had been working on scripting to make our live a little easier at work. One of the projects was the ability to send messages to users that are in other buildings or everyone. So after a few minutes of playing I got it to work and I thought I would share it with everyone. The script is a batch file that allows you to type in the message that you want to send out to the users. Then this batch file creates a VB Script that will be used to create the nice popup window on the remote machine. I have it writing the VBS script to a share to be accessed by the computers. So here it is.
@echo off
echo ***********************************************************
echo Tech Control Messaging System
echo ***********************************************************
echo.
echo.
echo Enter the message you want to send out to the
echo workstations at the prompt below.
echo.
echo.
echo.
set /p _mes=Enter the message:
echo x=msgbox (“%_mes%” ,64, “Messaging System” ) > c:\”share name”
psexec.exe @nodelist.txt -i -s -d wscript.exe \\”share name”\message.vbs
As you can tell it uses PsExec to connect to the systems. We use this with Windows 7 with out a problem. The VB Script creates a popup window with a warning icon and a OK button. This script also uses a list of computer names to send the message to called nodelist.txt. I am sure there are plenty of other ways to get the computer names but I like this way. The message window will look similar to the following picture:
If you don’t have a way to send out messages to users this is a good start. I hope this helps someone.
I set this up to write the file to a share on the network. This way I didn’t have to copy the file out to every machine. This way it will write the file to the share and then execute it on each machine from that share. You can change it to copy the file to the computers and then execute it. This way just works better for our network setup. C:\”Your share name” can be anything you want. You can place it on any drive and just share out that directory. Then just change the script to write the file to that location. Then have the script execute the file from your shares name.
I have a question, in the line
echo x=msgbox (“%_mes%” ,64, “Messaging System” ) > c:\”Your share name”
What we must put in c:\”Your share name”?