You want to send a pop-up message to one or more users on your network, something they'll see right away without requiring any special third-party applications to be running on their computers.
Sample code folder: Chapter 17\SendMessage
Use Windows's Net.exe program to send instant messages to named computers on your network.
The general syntax of the Net.exe command, when used to send instant messages, is of the form:
Net.exe Send ComputerName Message
You'll need to know the name of the computer to which you wish to send the message, or you may use "*" as the computer name to send a message to all computers on your network in one shot. If you specify a domain name as the target address, the message is delivered to all computers belonging to that domain.
You can use this command from a Command Prompt window, or you can use a Visual Basic 2005 application as a wrapper for the command. Create a new Windows Forms application, and add two TextBox controls named TargetComputer and MessageText. Also add a Button control named ActSend, and set its Text property to Send. Add informational labels if desired. The form should look something like Figure 17-14.
Figure 17-14. Controls for the message-sending sample
Now add the following code to the form's class template:
' ----- Send a message to another computer. Process.Start("net.exe", _ "send " & TargetComputer.Text & _ " """ & MessageText.Text & """")
The message you send appears in a message box on the other computer, similar to Figure 17-15.
Figure 17-15. A message received by the other computer
Both the sending and the receiving computer(s) must have the Messenger service running, or the message won't be sent. To enable this service under Windows XP, try the following steps:
This starts the Messenger service and causes it to restart each time Windows starts.