[python-win32] Automating logon/logoff

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


> -----Original Message-----
> From: python-win32-bounces at python.org 
> [mailto:python-win32-bounces at python.org] On Behalf Of Matt 
> Herbert (matherbe)
> Sent: Wednesday, October 17, 2007 11:02 AM
>
> I am stumped trying to figure out how I can automate the login/logoff
> procedure on Windows.
> [...] the hard part that I can't figure out, is how do I
programmatically
> initiate a logon, after a logoff? 

Hello all,

So I got busy doing other things, and I just got back to this earlier
this week. I thought that I would post back to the list with my results.
It turns out the only way I was able to find to do this, was through GUI
automation.

After studying some of the open source VNC code, I was able to figure
out how to switch desktop's to the 'Winlogon' desktop and send a
ctrl-alt-del key sequence. From there, it was a relatively simple matter
of using the winGuiAuto.py code (freely available on the internet) to
grab the handle of the logon box, find the handles of the username and
password entries, stuff my username and password into the entries, then
click the ok button.

Of course none of that can work, unless you are running as the SYSTEM
user, because it seems even Administrator users to not have the correct
permissions to access the Winlogon desktop.

I can post some sample code, if anybody is curious.

-Matt


More information about the python-win32 mailing list