Hugo,
I've been looking out on MSDN to find out more about WMI. Could you help get me started here.
I can at least see that you're creating a Locator object which in turn returns a Services object. From what I can tell, we get a collection of Win32_LoggedOnUser objects as a result of ExecQuery but I get confused as to what is happening in the GetObject() line. What is "Winmgmts:" and why can't I see an Antecedent property in the debugger for loCS objects?
Thanks for your help Hugo!
>Rodd, Here you have some code to test (it will require VFP 7+, I think):
>
>
>try
> loWBEMLocator = createObject("wbemScripting.SwbemLocator")
> loWMIService = loWBEMLocator.ConnectServer()
>catch
> loWMIService = null
>endtry
>
>if not Isnull(loWMIService)
> loCSs = loWMIService.ExecQuery('Select * from Win32_LoggedOnUser')
> for each loCS in loCSs
> try
> loUser = Getobject('Winmgmts:' + Strtran(loCS.Antecedent, '//', '/'))
> ? 'Domain : ', loUser.Domain
> ? 'Local? : ', loUser.LocalAccount
> ? 'Name : ', loUser.Name
> catch
> ? 'Error getting the User data'
> endtry
> endfor
>endif
>
>
>I this somewhat answers you question (Although I can not test for sure, I am only logged into my domain), the only problem is getting rid of the System accounts (Like SYSTEM, LOCAL SERVICE, NETWORK SERVICE, etc)