0

I need to show list of all users which connected to current computer and send each of them a message (by using command line). I am using '*.bat' I need to list all the users that connected to current computer, and send each of them message (by command line).

(I presume using 'net send' as on site: http://technet.microsoft.com/en-us/library/bb490710.aspx , but I need to know only the active users, as I can see on task manager -> users ,column status = active).

Thanks :)

Paul R
  • 208,748
  • 37
  • 389
  • 560
Eitan
  • 1,286
  • 2
  • 16
  • 55
  • `net send` was removed as of Windows Vista for security reasons, so it is no longer available. Type `net /?` from a command prompt to see the available options. There is no built-in way to send a message to "active users" AFAIK. – Ken White Oct 22 '14 at 15:27
  • Can you give me example, please. If not - How can I send message to users that are active (I need to get the list of the users, and do something like "foreach ..."). Thanks :) – Eitan Oct 22 '14 at 16:23
  • How can I give you an example of something I just told you is **NOT** available? There is no such way to send a message to users, active or not - they **removed it** in Windows Vista. – Ken White Oct 22 '14 at 16:49
  • 1
    @KenWhite Not exactly true. For Windows editions that can join domains (Pro, Enterprise, etc), the new `msg` utility is analagous to `net send`. – nobody Oct 22 '14 at 16:51
  • See http://stackoverflow.com/questions/4356053/advanced-uses-of-the-msg-command-in-a-batch-file – nobody Oct 22 '14 at 16:52
  • @AndrewMedico: According to [MSDN](http://technet.microsoft.com/en-us/library/cc771903.aspx), this only applies to Remote Desktop Sessions. It's not the same as `net send`, AFAICT. – Ken White Oct 22 '14 at 17:03
  • That seems to be misleading (all NT6 operating systems use the same "session" technology even if they're not remote desktop servers). It definitely works when run as a different user from a remote VM via `psexec` and it should work (possibly subject to privilege requirements) across machines in a domain by using the `/SERVER` switch to specify the target machine. – nobody Oct 22 '14 at 17:12
  • When I right click on task bar, and choose 'task manager' + users, I see all of the users and their status, so it seems obvious that there is a way to know somehow, by code which users. I may have write C# console code, and run the api. What is missing, that I need to return the command line a list (so, I can do foreach ...), if it can be done in command line (using foreach with the result of exe file. Is it possible somehow? If there is not any elegant way doing that, anyway ... – Eitan Oct 22 '14 at 20:10

1 Answers1

0

This is ancient, but as AndrewMedico says, msg gives you this functionality now in many versions of Windows.

If the only reason you wanted the usernames was to send them individual messages, you can just use msg * <message> which will send every user logged into that PC the same message.

If you wanted the usernames for another purpose, you can get these from a command prompt by typing query user. You could do some grepping of the results to just get a bare list of users if you require (and dont wish to use other methods of getting these users such as C#).

WiredEarp
  • 383
  • 3
  • 11