Wednesday, June 1, 2011

How to use msg.exe to send popup messages to multiple PCs / Workstations



Remember the glorious days of net send? Admittedly some of us used to scare the lives out of our 'favourite' users by sending them "C Drive format commencing in 30 seconds" and the such... I will not disclose names but what I can say is that it was in the early, immature days in their careers.

In actual fact, the 'net send' command was an extremely useful tool for sending messages to users that they simply couldn't ignore and what's more, couldn't claim they didn't notice. There were of course some security concerns, which is why in most environments the messenger service stayed disabled in user workstations.

Well, with the introduction of Vista and 2008 Server we waved the good ol' days of 'net send' goodbye! Enter msg.exe which was well... the same bar one little but very important detail: you cannot send messages to multiple PCs! The dependence of some IT departments on this functionality was lost on me until a recent case with a client. Apparently, being able to message multiple computers in one command was very important and some form of alternative was needed.

To avoid going with 3rd-party software, I came up with this command line script workaround. Here it is:

Copy-paste the following lines into a text file and rename it to netsend.bat

:input
@echo off
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="" goto input
cls
echo Your input was: %INPUT%
echo Hit any key to proceed, or CTRL-C to cancel
pause
FOR /F %%p IN (pcs.txt) DO msg * /server:%%p %INPUT%

Now create another text file and name it pcs.txt. List all workstations that you want to message in it, but make sure there are no spaces or empty lines. Here's an example:



Last but not least you'll need to change a registry setting in all workstations you want to message. Copy-paste the following text into a text file, and rename it to netsend.reg

Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]
"AllowRemoteRPC"=dword:00000001

Now run the file on each target workstation to import the setting into the registry.

If you're managing a large domain network you can put the reg file in a GPO and link it to the OU(s) of the target workstations. Similarly, to avoid having to manually type tens or hundreds of PC names in pcs.txt, you can use PowerShell to export the workstation names from Active Directory to a text file.

So, there you go! Just open a command line window, run netsend.bat, type in the message you want to send and voila!! Faith in the 2008/R2 system restored!!!
 

12 comments:

  1. Very simple and it actually works. The first solution I have come across that does do exactly what it says. Thank you!!

    ReplyDelete
  2. Works great, for small list of computers.

    On larger scale, the problem is that if one has a large list of computers or ip-addresses, where some of those are not online (for example ip range or names exported from AD), it takes quite a lot of time for it to timeout those absent names / adresses, as it goes through those one at the time, and not all in the same time...

    ReplyDelete
  3. Quite right, a more elegant solution is in order...

    ReplyDelete
  4. popup messaging - working fine. thanks for the solution

    ReplyDelete
  5. i tried and it work on windows 7 PC's but did not work for Windows XP. Please sugest

    ReplyDelete
  6. got it. fow windows XP you need to restart the XP machine to take effect after registry changed.

    ReplyDelete
  7. hi, i have been trying to try this. no luck so far. should i run the command on the server? should i put both netsend.bat and pcs.txt in one directory?

    ReplyDelete
  8. FOR /F %%p IN (pcs.txt) DO msg * /server:%%p %INPUT%

    should i replace entry server with the actual sever name?

    ReplyDelete
  9. and should i replace (pcs.txt) with the full path ofthe file location?

    ReplyDelete
    Replies
    1. you dont need to change anything, just have pcs.txt in same folder as the .bat or .cmd file and it reads it fine, as for the /server you leave that and define the names in the pcs.txt file

      Delete
  10. Does this work for Windows 2012R2?
    After i run it nothing pop up on my client pcs.

    ReplyDelete
  11. Today work for all Windows Systems, since XP to 10

    ReplyDelete

Total Pageviews

Labels

Search This Blog

Popular Posts