Win32 API question - Postmessage and Win2K lock window

dsavitsk dsavitsk at e-coli.net
Mon Jul 29 17:29:19 EDT 2002


I have found, I think, that when a service runs as a particular user, any
applications launched by the service also run as that user.  I use this so
that when a service launches Word it uses my Normal.dot file.  setting up a
service to run as you to launch the defrag utility might work.  of course,
you can just use the scheduler to launch defrag...

if you do need to send key strokes, you might try using PC Anywhere or its
kin.


"Mark Erikson" <markulus00 at yahoo.com> wrote in message
news:4d3df955.0207291235.1a8916b at posting.google.com...
> Hey, folks.  I've got a problem regarding the PyCwnd.PostMessage()
> function behind the Windows 2000 lock window.  I know this is more of
> an API question than a Python question, but figured it was worth
> asking here just in case.
>
> Basics of the issue:
> I'm trying to automatically launch the Windows 2000 Defrag utility.
> While any user can launch it, the defrag function can only be
> activated by an administrator.  By getting the window handle and
> creating a PyCwnd from the handle, I can do PostMessage() to the
> window and send WM_KEYUP and WM_KEYDOWN messages.  When run as an
> administrator, I can successfully simulate the keystrokes needed to
> start the defragmentation.  However, this needs to be run on other
> users computers, most likely during lunch.  So, I've been working with
> Win2K's "runas" utility.  It requires that a password actually be
> typed in, though no input is visible.  Again, I can use PostMessage to
> send simulated keystrokes to the Command Prompt window, runas
> completes successfully, Defrag launches, and everybody's happy.  The
> problem comes when I try to deal with people using the CTRL-ALT-DEL
> "Lock Window" function, which absorbs any standard keyboard input
> (which is why I'm using WM_KEYUP/DOWN instead of a more standard
> SendKeys type deal).  If I'm just running Defrag, I can still
> successfully use PostMessage() and activate it.  *IF*, on the other
> hand, I launch Runas behind the lock window, *I cannot send the
> keystrokes*.
>
> I've looked at everything from using pipes to replace stdin to using
> other Runas-type utilities (SU, sfImpersonator, etc) to using
> WriteConsole() to too much other stuff to remember.  Nothing I've
> experimented with has seemed to work.
>
> So... does anyone have any ideas?  I just need to be able to simulate
> keystrokes for a password to a Command Prompt window for which I have
> a handle, BEHIND the Win2K lock window.  I'm open to any suggestions,
> including stuff that I've looked at already (since it's quite possible
> I missed something).
>
> Thanks in advance!
>
> Mark Erikson
>
> markulus00 'at' yahoo 'dot' com





More information about the Python-list mailing list