Question

I'm trying to get a list of currently-open sessions in Python via WMI.

What I'm after is the exact information displayed in the Computer Management thingy, when you go to System Tools -> Shared Folders -> Sessions (ie username, computer name, connected time, that sort of thing).

I know (or at least believe) it has something to do with Win32_ConnectionShare...

If it makes a difference, I'm using Tim Golden's wmi module.

Of course, if there's another (non-WMI) way of getting this information then that's welcome too...

Was it helpful?

Solution

Never mind -- I found it:

>>> import wmi
>>> c = wmi.WMI()
>>> for x in c.Win32_ConnectionShare():
        print "%s: %s" % (x.Dependent.Username, x.Dependent.ComputerName)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top