"John Puopolo" <jo**********@fastsearch.com.nospam> wrote in message
news:u4**************@TK2MSFTNGP10.phx.gbl...
All:
I am writing a "net send" like application. The application runs on each
person's PC, waiting for messages.
Let's suppose "Joe" is logged in to 2 PCs, A and B. I would like to enter
acommand (from my PC) like: sendto joe hello
I would then like a window to pop up on PC A and PC B with "hello." In
order to do this, I need a way to determine all of the computers where Joe
is logged in as user.
the psuedocode is something like:
foreach (node on the network) {
if (user logged in is target_user) {
send target_user the_message
}
}
Is this possible?
Yes, using System.Management and WMI.
Note that this requires access privileges to the remote systems WMI service
to run.
string machineName = "remote";
ConnectionOptions options = new ConnectionOptions();
options.Username = "someuser"; //user (domain or local) with sufficient
privileges to access the remote system through WMI
options.Password = "secret";
ManagementScope s = new ManagementScope("\\\\" + machineName +
"\\root\\cimv2", options);
ManagementPath p = new ManagementPath("Win32_ComputerSystem.Name='" +
machineName +"'");
using(ManagementObject cs = new ManagementObject (s, p, null ))
{
cs.Get();
Console.WriteLine(cs["UserName"]);
}
Willy.