?
Solved

Problem with msg command

Posted on 2015-02-20
12
Medium Priority
?
1,712 Views
Last Modified: 2015-03-04
Each user on our network is running Windows 7 and might login to a different computer depending on the day and the status of the employee.  Supervisors need a script they can run that will allow the to produce a small nag screen in the form of a broadcast message that the user might have to move out of the way before they can work.  

The nag screen should allow the supervisor to choose from among her own saved list of employees and send a broadcast message or nag screen to one or more of them forcing them to move it from the center of the screen before they can continue their work.

We are not certain that we have any support from the I.T. department on this and we are not allowed to install software.

Initially, I am thinking to use the msg command which replaces the old netsend command.  If I type my username, it displays a message, but if I type someone elses username, I get the message "username does not exist or is disconnected".  I get this message even though I know them to be currently active and logged in.  I have tested this approach with a number of users and get the same message.

Assistance in scripting a solution in powershell is greatly appreciated.
0
Comment
Question by:frugalmule
  • 6
  • 5
12 Comments
 
LVL 19

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 336 total points
ID: 40622936
check if RPC is allowed on the remote PC where the other is logged on.
on remote PC, open registry:
regedt32
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
See if the following key exists:
AllowRemoteRPC   value 1   (change to 1 if 0)

restart the remote PC and test
0
 

Author Comment

by:frugalmule
ID: 40623077
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control is listed but \Terminal Server is not, even on my PC
0
 

Author Comment

by:frugalmule
ID: 40623083
I openned an Windows remote desktop connection to see what error would be reported and it said "The connection was denied because the user account is not authorized for remote login".
0
NEW Internet Security Report Now Available!

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out this quarters report on the threats that shook the industry in Q4 2017.

 
LVL 26

Assisted Solution

by:Coralon
Coralon earned 1664 total points
ID: 40623881
The way msg.exe works is either by username (as you have seen), by session NAME, by session ID, or you can do a blast wildcard to get all the users on a machine.

The real question is do you need to specify which machine is getting the message for a specific user?  Msg.exe is not a broadcast command, it is a directed command.  As an example:
msg * /server:servername This is my test message
[code]

This will send a message dialog to all users on servername that says "This is my test message".

If you don't need to worry about what machine a user is on, then you would take a list of computers and do a simple [code]for /f %f in (computerlist.txt) do msg * /server:%f this is my message text

Open in new window


Now, if it *does* matter, then it gets much more complicated, because you will need a list of all the machines, and the specified usernames..  Powershell makes it easier to parse, but you will need to have powershell remoting enabled on all the machines.

But, from a batch file perspective, you could do something like this:
for /f %f in (computerlist.txt) do (
for /f %A in (userlist.txt) do (
for /f %K in ('quser /server:%f') if %K == %A then msg.exe %A /server:%f This is my warning text
)
)

Open in new window


Be aware, the % variables are case-sensitive.  

Coralon
0
 

Author Comment

by:frugalmule
ID: 40624734
Hi,

Your suggestion msg * /server:servername This is my test message seems to return a message to me if I put in my computer name or someone elses, but does not display the message for the end user.
0
 
LVL 26

Assisted Solution

by:Coralon
Coralon earned 1664 total points
ID: 40624927
It will show up for everyone logged in interactively. I.e. If you run your msg against a Remote Desktop server, all the users logged into that machine will get the message.

It will not show for users logged into the network.

Coralon
0
 

Author Comment

by:frugalmule
ID: 40624930
What I am saying is that it isn't displaying the message.
0
 
LVL 26

Assisted Solution

by:Coralon
Coralon earned 1664 total points
ID: 40624990
Are you an admin on those machines?

Coralon
0
 

Author Comment

by:frugalmule
ID: 40624993
Unfortunately not
0
 
LVL 26

Assisted Solution

by:Coralon
Coralon earned 1664 total points
ID: 40636648
I've always been an admin using it.  I will give it a shot over the weekend and see what I can find.

Coralon
0
 

Author Comment

by:frugalmule
ID: 40637399
Great.  I woud appreciate that very much.
0
 
LVL 26

Accepted Solution

by:
Coralon earned 1664 total points
ID: 40639958
I did just test it, and you do have to have admin rights on the box that is receiving the message.  If you do not, it cannot enumerate any sessions and won't send to them.

Coralon
0

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

The Windows Firewall provides an important layer of protection and a rich interface to configure it. Unfortunately, it lacks item level filtering. This article details my process of implementing firewall-as-code to reduce GPO bloat.
This article is divided into two sections. 1) First describes how you can connect to server / service / device with Username and secure password in powershell. 2) Second part is to use secure credentials and connect to vCenters which are in Link…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

568 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