How can I send a broadcast alert message to my Win 7 AD-joined machines?

I'm beginning to deploy Windows 7 to the university, and would like to replicate our Novell broadcast message feature in our new AD environment.  

We run SCCM, so I understand that a possibility exists there, but we need it to be a more immediate message if it were a physical security situation.

MU-ITAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
omgangConnect With a Mentor Commented:
<<This doesn't send messages out to everyone in the domain, just the machine I'm on.>>

Yes, but msg.exe can be used to provide the functionality you're looking for.  Try this from a command prompt substituting in an IP address of another machine on your network to receive your message.
msg * /SERVER:192.168.1.25 /TIME:15 This is a test message
The /TIME parameter specifies how long the message is to be displayed on the recipient machine.

I developed a vb script applet to send emergency popup messages to users.  Originally developed utilizing the Messenger service and NET SEND command I recently updated it to be Vista/7 compatible.  The trick with msg.exe is that the user must have administrator rights to execute.  I worked around this by wrapping the msg.exe command in a RunAs command.

For my app I am using an initialization file for many of the variables but I've posted code below that doesn't depend upon an ini file.

This won't broadcast a message to all machines in a domain but it can/will send individual messages to all the machines specified in the recipient file.  Machines can be specified by name or by IP address.  With a little tweaking you can set your recipient text file up with IP subnets and have the script iterate through each address in the subnet and issue the msg.exe command to each address.  A sample of the recipient text file would be
192.168.1.
192.168.2.
192.169.100.
I have a vbs example of how to do this as well.


OM Gang

'force explicit declaration of all variables
Option Explicit

'send a network broadcast message to a list of recipients (machines) contained in a text file located
'at the path specified

            'constant indicating how text file should be opened
      Const ForReading = 1

            'declarations
      Dim objNet, RootDSE, objConnection, objCommand, objRecordset, objFSO, objTextFile, wshShell
      Dim intDelay, intSleep
      Dim strRecipFile, strMsg, strUserName, searchRoot, strQueryText, strPass, strINIFile
      Dim strNetCmd, strRunAsCmd, strThisComputer, strDestComputer, strFullCmd, strFilePath
      Dim strINIContents, strErrMsg
      
            'local workstation admin password -- for testing we're reading this from the ini file but
            'for production we'll hard code in and compile into executable
      strPass = "adminpass"

            'instantiate file system object for use in this procedure and related functions
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      
            'get directory path for ini and recipient files script execute argument
      'strFilePath = WScript.Arguments(0)
      
            'make sure we have a non-empty string for a directory path
      'If strFilePath = "" Then
      '      strErrMsg = "No valid path for initialization and recipient files."
      '      MsgBox strErrMsg, vbCritical
      '      WScript.Quit
      'End If
      
            'call function to load full contents of initialization file into string variable
      'strINIContents = GetFile(strFilePath & strINIFile)
            'exit script in empty string returned
      'If strINIContents = "" Then WScript.Quit

            'call function to retrive ini file keys
            'get recipients list file name from ini file
      strRecipFile = "c:\temp\MyRecipientFile.txt"            'if key value is not present exit script
      If strRecipFile = "" Then
            strErrMsg = "Initialization is missing key FILENAME or it is not set."
            MsgBox strErrMsg, vbCritical
            WScript.Quit
      End If
      
            'get message text from ini file
      strMsg = "This is the broadcast message text"            'if key value is not present exit script
      If strMsg = "" Then
            strErrMsg = "Initialization file section Message Text, keyname TEXT is missing or unassigned."
            MsgBox strErrMsg, vbCritical
            WScript.Quit
      End If
      
            'get TTL in seconds for message from ini file
      intDelay = 30      
            'get pause interval in milliseconds for passing password from ini file
      intSleep = 500      
            'get local machine admin password from ini file -- following line to be commented out/removed
            'in production version
      'strPass = ""
            'get currently logged on username and local computer name
      Set objNet = CreateObject("WScript.Network")
      strUserName = objNet.UserName
      strThisComputer = objNet.ComputerName

            'call function to convert logged on userID to full name
      strUserName = GetFullName(strUserName)
      
      On Error Resume Next
            'open emergency broadcast recipients text file so we can iterate through the list of recipients
      Set objTextFile = objFSO.OpenTextFile(strFilePath & strRecipFile, ForReading)
            'trap error when file not found
      If Err.Number = 53 Then
            strErrMsg = "Recipients text file " & strFilePath & strRecipFile & " not found."
            MsgBox strErrMsg, vbCritical
            WScript.Quit
      End If
      On Error Goto 0
      
            'build RunAs command so we can execute msg command as priveleged user
      strRunAsCmd = "runas /noprofile /user:" & strThisComputer & "\administrator "

            'build command to send network message
      strNetCmd = "msg * /server:"

      Set wshShell = CreateObject("WScript.Shell")

            'iterate through each line in the text file and issue the shell command for each
      Do While Not objTextFile.AtEndOfStream
            strDestComputer = objTextFile.ReadLine
            strFullCmd = strRunAsCmd & Chr(34) & strNetCmd & strDestComputer & " /TIME:" & intDelay & " " & _
                        strUserName & " " & strMsg & Chr(34)
            wshShell.Run strFullCmd
            WScript.Sleep intSleep
            wshShell.SendKeys strPass & "~"
                  'pause execution for a bit to allow previous command to execute
            WScript.Sleep 250
      Loop

            'close the text file
      objTextFile.Close

      WScript.Quit



Function GetFullName(strUserName)

      Dim strFName, strLName, strFullName
      
            'search AD for this logon account and get the users first and last name
      Set RootDSE = GetObject("LDAP://RootDSE")
      searchRoot = RootDSE.Get("defaultNamingContext")

      Set objConnection = CreateObject("ADODB.Connection")
      Set objCommand = CreateObject("ADODB.Command")
      objConnection.Provider = "ADsDSOObject"
      objConnection.Open "Active Directory Provider"
      Set objCommand.ActiveConnection = objConnection

      strQueryText = "<LDAP://" & searchRoot & ">;(&(objectCategory=Person)(samAccountName=" & strUserName &"));" _
                  & "givenName,sn,ADsPath;SubTree"
      objCommand.CommandText = strQueryText
      objCommand.Properties("Page Size") = 2000
      objCommand.Properties("Timeout") = 60
      objCommand.Properties("Cache Results") = False
      Set objRecordSet = objCommand.Execute
      objRecordSet.MoveFirst

            ' --- Loop through the returned records
      Do Until objRecordSet.EOF
            strFName = objRecordSet.Fields("givenName").value
            strLName = objRecordSet.Fields("sn").value
            objRecordSet.MoveNext
      Loop

            'concatenate current users first and last name and assign to new variable
      strFullName = strFName & " " & strLName
      
            'function return value
      GetFullName = strFullName

End Function
0
 
NotVeryFatCommented:
Crude, but very basic, would MSG work? (Type msg /? in a command prompt)
0
The eGuide to Automating Firewall Change Control

Today’s IT environment is constantly changing, which affects security policies and firewall rules. Discover tips to help you embrace this change through process improvement & identify areas where automation & actionable intelligence can enhance both security and business agility.

 
MU-ITAuthor Commented:
This doesn't send messages out to everyone in the domain, just the machine I'm on.
0
 
cdesignerCommented:
Do you need a free solution?
0
 
MU-ITAuthor Commented:
Preferebly.  Do you have a pay-for solution in mind?
0
 
mrroonieCommented:
you could roll this out via GP - http://www.winpopup.net/

"LAN winpopup software supports mass messaging to all your PC users. This option help to notify about important events"
0
 
cdesignerCommented:
Contact them:
http://www.cezeo.com/solutions/one-way-instant-messenger/

They have huge discounts for .edu
0
 
MU-ITAuthor Commented:
In just trying a machines IP, with the firewall off and the registry key in place for "Allow RPC" per:  

http://social.technet.microsoft.com/Forums/en-US/itprovistanetworking/thread/257ac6da-1d9f-4354-8e40-128e11c319ee/

I still get the "Error 1722 getting session names"
0
 
omgangCommented:
Do you have admin rights on the machine?
OM Gang
0
 
omgangCommented:
And are you issuing this exact command?
msg * /SERVER:192.168.1.25 /TIME:15 This is a test message

OM Gang
0
 
MU-ITAuthor Commented:
Yes, that exact command (with the appropriate IP in it's place), and my id is in the administrators group.
0
 
omgangCommented:
Try to your own IP address.
If possible try logging in as local admin and issuing the command.  I recall receiving errors on machines when running as standard user.
OM Gang
0
 
MU-ITAuthor Commented:
I've got it working with the command: msg /SERVER:192.168.1.25  * This is a test message

after additionally  changing the registry key fDenyTSConnections from 1 to 0, and applying a reboot.

using "msg /Server:* * this is a test message" doesn't  work.
using "msg /server:machinename * this is a test message" doesn't work.

I worry about an iterative script through our various subnets (we've got a Class b) taking longer than whatever event we're trying to announce.  It takes a few seconds just to do a single machine.

0
 
omgangCommented:
With the delays I have built in for passing the admin password and the delay to let the previous command to process before issuing the next command I am expecting 30-50 seconds per 100 messages.  Might be able to tweak that down a bit with further testing.
Options to speed up messge delivery include mulitple scirpts each targeting some number of machines and a single script to call them all.....does that sound a bit like 'Lord of the Rings'?  "one ring to rule them all......
Sorry, I often get sidetracked.
Of course msg.exe may not be suitable for your situation.  I was just pointing out that it can be used.
OM Gang
0
 
MU-ITAuthor Commented:
No, I believe it will work perfectly for us.  I've trimmed some stuff out of the script, and am working on the iterative subnet functionality.  

Points forthcoming.

0
 
MU-ITAuthor Commented:
Thanks!
0
 
MU-ITAuthor Commented:
It would be of further help if you could provide your subnet example, please.
0
 
omgangCommented:
Example to issue the message to ip addresses 25 through 50 on the subnet specified in the recipient file.  For total coverage you'd use 1 to 254
OM Gang

Add to declarations
Dim intCounter, FirstAddy, LastAddy

FirstAddy = 25
LastAddy = 50




            'iterate through each line in the text file and issue the shell command for each
      Do While Not objTextFile.AtEndOfStream
            strDestComputer = objTextFile.ReadLine      '<---- each entry is a subnet, e.g. 192.168.1.
      For intCounter = FirstAddy to LastAddy
                    strFullCmd = strRunAsCmd & Chr(34) & strNetCmd & strDestComputer&intCounter & " /TIME:" & intDelay & " " & _
                                    strUserName & " " & strMsg & Chr(34)
                    wshShell.Run strFullCmd
                    WScript.Sleep intSleep
                    wshShell.SendKeys strPass & "~"
                          'pause execution for a bit to allow previous command to execute
                    WScript.Sleep 250
                Next
      Loop








              'broadcast - get subnet ID from text file and send a message to all available addresses
          For intCounter = FirstAddy to LastAddy
                  'build the full command we want to issue in the shell
              strFullCommand = strCommand & " " & strRecipMachine & intCounter & " " & strFullMessage
              wshShell.Run strFullCommand
              'MsgBox strFullCmd, OK, "command"
          Next
0
 
omgangCommented:
Sorry, disregard the code at the bottom of my last post (the code that begins with 'broadcast.....) as that's what I copied from one of my scripts.
OM Gang
0
All Courses

From novice to tech pro — start learning today.