While I don’t have a huge environment to test in, this seems to work remotely from my win 10 pc to my Windows Server 2016 which has remote admin RDP enabled… I would assume it’s the same APIs to talk to a full fledged WTS Server.
Kudos to the internet for having the answer already written down for me… even if it was in python 2 syntax (what else should I expect from a post in 11/2007?). 😊 https://mail.python.org/pipermail/python-win32/2007-November/006425.html import win32ts for s in win32ts.WTSEnumerateSessions(win32ts.WTSOpenServer("MYSERVER.MYDOMAIN.COM"),1): if s['State'] == win32ts.WTSActive: print(f"Session is active: {s}") output: Session is active: {'SessionId': 1, 'WinStationName': 'RDP-Tcp#124', 'State': 0} take a look at win32ts here: http://timgolden.me.uk/pywin32-docs/win32ts.html I am guessing you would also want to use “WTSQuerySessionInformation” as well to get more detailed information about the session, but I will leave that to you to explore. I just found this today, so I am no expert on use of this module but it looks GREAT and I will likely develop something with it myself eventually. Steven From: python-win32 <python-win32-bounces+steven=manross....@python.org> On Behalf Of Craig R. Matthews Sent: Saturday, March 12, 2022 12:02 AM To: python-win32@python.org Subject: [python-win32] pywin32 question I was wondering if there is a way in python to determine the idle time for a terminal server session as QUERY USER does. Also, is there a way to get that python code to run for a server other than the one running the code (as in QUERY USER /SERVER:name)?
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32