MSG - CMD


Overview

The MSG command in Windows CMD is used for sending messages to users and sessions on a local or remote machine that is running the server service. It is particularly useful in administrative tasks, network management, and instant messaging across office environments where users are logged on to the same or interconnected Windows systems.

Syntax

The syntax for using the MSG command is as follows:

MSG {username | sessionname | sessionid | @filename | *} [/SERVER:servername] [/TIME:seconds] [/V] [/W] [message]
  • username: Send a message to a specific user.
  • sessionname: Send a message to a specific session.
  • sessionid: Specify the session ID to send the message.
  • @filename: Send a message to users whose names are stored in the specified file.
  • *: Send a message to all sessions on the specified server.

Parameters

  • /SERVER:servername: Specifies the server to which the message will be sent. The default is the local server.
  • /TIME:seconds: Specifies the duration for which the message is displayed. The default setting depends on system notification settings.
  • /V: Displays information about the actions being performed.
  • /W: Waits for the user to acknowledge the message before closing.

Options/Flags

  • /SERVER: Useful for network admins to send messages across servers in a multi-server environment.
  • /TIME: Set a time limit for how long the message will appear on a user’s screen.
  • /V: Verbose mode, provides detailed command action outputs.
  • /W: Ensures that the sender knows the message has been seen, which is useful in critical communication.

Examples

  1. Simple Message to a User:

    MSG david "Please submit your report by 5 PM."
    

    Sends a message to user ‘david’ on the local machine.

  2. Message to All Users on a Server:

    MSG * /SERVER:server01 "Server will restart in 10 minutes."
    

    Sends a broadcast message to all users on server01 about an impending restart.

  3. Message with Timeout:

    MSG * /TIME:30 "Quick system check in 5 minutes. Save your work."
    

    Sends a broadcast message that will last for 30 seconds before disappearing.

  4. Using a File to Send Messages:

    MSG @userlist.txt "Please attend the team meeting at 3 PM in Room 402."
    

    Messages every user listed in userlist.txt.

Common Issues

  • User Permission Denied: Users might receive an error if they do not have permission to send messages. Make sure to run CMD as an administrator.
  • Server Not Found: Ensure the server name is spelled correctly and that network connectivity is intact.

Integration

Combine MSG with other commands like SCHTASKS for scheduled messages:

SCHTASKS /Create /SC HOURLY /TN "HourlyReminder" /TR "MSG %username% 'Hourly check-in reminder'"

This schedules an hourly message reminding users to check in.

  • NET SEND (deprecated): Previously used in older versions of Windows to send network messages.
  • SCHTASKS: Schedule commands and scripts to run at a specific time or when certain conditions are met.

For more detailed information, refer to the Windows official CMD documentation on Microsoft’s website.