[python-win32] how to use CreateProcessWithLogonW

Tim Roberts timr at probo.com
Mon Jun 1 19:32:56 CEST 2009

Emin.shopper Martinian.shopper wrote:
> Dear Experts,
> Can someone provide an example of how to use CreateProcessWithLogonW?

It's really just a combination of LogonUser and CreateProcess.  It uses
the first four parameters you passed to LogonUser, plus the parameters
you would have passed to CreateProcess.  You can look at the source code
to subprocess to see how they call CreateProcess.  In fact, perhaps you
could use that as a base, passing in your login credentials as an
additional parameter.

Processes created by CreateProcessAsUser don't have access to the
desktop, by default.  Do you need UI?  If so, you'll need to read

> Any advice on either spawning subprocesses which inherit parent user
> properly or changing users in a better way on Windows would be greatly
> appreciated.

Unfortunately, this is a maze of twisty passages, all alike.  It is a
complicated and not well known part of the Windows API, and you will end
up doing a lot of very frustrating experimentation.

Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

More information about the python-win32 mailing list