[python-win32] Logging off of windows

Matt Herbert (matherbe) matherbe at cisco.com
Fri Nov 9 21:25:51 CET 2007


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)

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


More information about the python-win32 mailing list