Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where to get started - Log off user

0 views
Skip to first unread message

Elp

unread,
Dec 10, 2004, 7:34:55 AM12/10/04
to
Hi,

Does anybody knows a good place where a reasonably experienced C#
programmer who knows nothing about WMI could get easy to understand info to
get started with WMI? I've not been able to find any good WMI site for
beginners using C#. Most sites are about scripting.

For example, i'm trying to write a function that allows a Windows Service
to log off a user on the local machine (either physical user or XP remote
desktop user). I've been able to come up with that:

ManagementObjectSearcher searcher = new ManagementObjectSearcher();
ManagementObjectCollection objectCollection;
object[] myParams = {4, 0};

searcher.Query.QueryString = "SELECT * FROM Win32_OperatingSystem";
objectCollection = searcher.Get();
foreach (ManagementObject managmentObject in objectCollection)
{
managmentObject.InvokeMethod("Win32Shutdown", myParams);
}

This code works great when a user is logged in "physically" but not with XP
Remote Desktop users. As i don't know how WMI really works, i can't find
the reason why this doesn't work with a Terminal Services user.

Any help or links would be really appreciated.

Thanks

Glenn Wilson

unread,
Dec 13, 2004, 2:55:56 AM12/13/04
to
There are not many around yet, I looked to the scripting centre on Technet,
and started to convertthe vbscript...

"Elp" <rockf...@REMOVEME.hotmail.com> wrote in message
news:147zkwu7d5qs0.2...@40tude.net...

0 new messages