Solved

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

Posted on 2011-03-16
20
6,209 Views
Last Modified: 2012-05-11
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.

0
Comment
Question by:MU-IT
  • 8
  • 7
  • 3
  • +2
20 Comments
 
LVL 9

Expert Comment

by:cdesigner
ID: 35147679
0
 
LVL 5

Expert Comment

by:NotVeryFat
ID: 35147692
Crude, but very basic, would MSG work? (Type msg /? in a command prompt)
0
 

Author Comment

by:MU-IT
ID: 35147714
This doesn't send messages out to everyone in the domain, just the machine I'm on.
0
 
LVL 9

Expert Comment

by:cdesigner
ID: 35147851
Do you need a free solution?
0
 

Author Comment

by:MU-IT
ID: 35147861
Preferebly.  Do you have a pay-for solution in mind?
0
 
LVL 13

Expert Comment

by:mrroonie
ID: 35147916
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
 
LVL 9

Expert Comment

by:cdesigner
ID: 35147957
Contact them:
http://www.cezeo.com/solutions/one-way-instant-messenger/

They have huge discounts for .edu
0
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
ID: 35147996
<<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
 

Author Comment

by:MU-IT
ID: 35148224
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
 
LVL 28

Expert Comment

by:omgang
ID: 35148284
Do you have admin rights on the machine?
OM Gang
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 28

Expert Comment

by:omgang
ID: 35148302
And are you issuing this exact command?
msg * /SERVER:192.168.1.25 /TIME:15 This is a test message

OM Gang
0
 

Author Comment

by:MU-IT
ID: 35148317
Yes, that exact command (with the appropriate IP in it's place), and my id is in the administrators group.
0
 
LVL 28

Expert Comment

by:omgang
ID: 35148463
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
 

Author Comment

by:MU-IT
ID: 35148741
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
 
LVL 28

Expert Comment

by:omgang
ID: 35149096
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
 

Author Comment

by:MU-IT
ID: 35149114
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
 

Author Closing Comment

by:MU-IT
ID: 35149123
Thanks!
0
 

Author Comment

by:MU-IT
ID: 35149142
It would be of further help if you could provide your subnet example, please.
0
 
LVL 28

Expert Comment

by:omgang
ID: 35149490
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
 
LVL 28

Expert Comment

by:omgang
ID: 35149508
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

OfficeMate Freezes on login or does not load after login credentials are input.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now