msg
The msg command in Windows is used to send messages to users, sessions, or server machines. Here’s a breakdown of the command and its options:
msg {<username> | <sessionname> | <sessionID>| @<filename> | *} [/server:<servername>] [/time:<seconds>] [/v] [/w] [<message>]
Parameters
- <username>: The username of the person you want to send a message to.
- <sessionname>: The name of the session you want to send a message to.
- <sessionID>: The ID of the session you want to send a message to.
- @<filename>: A file containing a list of usernames or session IDs to whom you want to send the message.
- *: Sends the message to all users on the local machine.
Optional Parameters
- /server:<servername>: Specifies the server where the message should be sent. If not specified, it sends the message to the local machine.
- /time:<seconds>: Specifies how long the message should be displayed on the recipient's screen. The default is 60 seconds.
- /v: Displays information about the message being sent.
- /w: Waits for the message to be acknowledged before returning to the command prompt.
Message
- [<message>]: The actual message text you want to send.
Examples
Sends the message "Hello, this is a test message." to the user with the username username.
msg username "Hello, this is a test message."
Sends the message to all users currently logged into the local machine.
msg * "Attention, the system will be rebooted in 10 minutes."
Sends the message "Please save your work." to the session with ID 1.
msg 1 "Please save your work."
Sends the message "Your session will expire in 2 minutes." to the user, which will be displayed for 120 seconds.
msg username /time:120 "Your session will expire in 2 minutes."