Thanks Roger, That worked perfectly!
import win32ts for s in win32ts.WTSEnumerateSessions(win32ts.WTSOpenServer("."),1): if s['State'] == win32ts.WTSActive: print "Session is active" -Matt > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Roger Upole > Sent: Sunday, November 11, 2007 1:21 AM > To: python-win32@python.org > Subject: [python-win32] Logging off of windows > > Matt Herbert wrote: > > > > Hello all, > > > > I'm having a little problem figuring how I can tell if > there is anybody > > currently logged into windows at the desktop. More > specifically, I am > > initiating a logoff via the ExitWindowsEx() function and, as we all > > know, it can sometimes take a little bit for the logoff to actually > > complete (my system takes anywhere from 3 to 20 seconds). > > > > The problem is ExitWindowsEx() return's immediately. But I > don't want to > > do anything until the logoff process has completed and we > are sitting > > happily at the logon screen. > > > > So just to give a little perspective on this, I have a > service that runs > > all the time, for automated testing. The service need's to > perform some > > test's at the desktop, and other tests at the logon screen. > I need to be > > sure, that after I've logged a user off, that the logoff process has > > completed, and we are indeed at the logon screen. > > > > I have tried using: > > > > deskh = win32service.GetThreadDesktop(win32api.GetCurrentThreadId()) > > name = > > win32service.GetUserObjectInformation(deskh,win32service.UOI_NAME) > > This will return information for the desktop on which the > service is running, which > is usually not the interactive desktop. Both are named > Default, but exist in different > window stations. In fact, on Vista services run in an > entirely separate session > from the interactive session, and interacting with it is restricted. > > > but that always returns "Default", even after the user has > logged out. > > I'm not really sure where to go next. > > > > Do any of you very smart people have any good idea's on how > I can solve > > this problem? > > > > -Matt > > You may be able to use win32ts.WTSEnumerateSessions to check if the > console session is currently active. > > Roger > > > > _______________________________________________ > python-win32 mailing list > python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32