CreateProcessWithLogonW access denied



I have an app that runs as the windows shell under an autologged on
limited user. This app calls CreateProcessWithLogonW to start an
application under an administrator account. There is a timing issue
where the CreateProcessWithLogonW function returns "access denied"
unless I wait a given amount of time before I try to start the
process. The times needed are different on different machines and
different versions of Windows (2000 / XP). Sometimes it is 20 seconds
others it is 180 seconds.

My hypothesis is that since my app is the shell and it starts at boot
time, Windows has not fully finished initializing and/or the
administrator account is not ready when my app tries to start the
other process under the other account (registry hive).

Does anyone have any clue what the problem is and if so any
solutions? Any suggestions of other places or groups to submit my

Thanks for any help.

Newbie Coder


If you look at the MSDN documentation for this function you will see that
you need to load the users profile into HKEY_USERS before calling the
CreateProcessWithLogonW function. If not, it will fail

It also says in XP to use CreateProcessAsUser & LogonUser, but one thing
with this is that if you call LogonUser under Windows 2000 it will fail
because you need to specify ACT AS PART OF THE OPERATING SYSTEM in the
policy settings, which will remove security & not something you want to do.
Also, remember that XP uses plain text passwords so if you don't want
someone to retrieve the password then you will need to ZeroMemory the very
second you can.

VB 6 Code (easily converted):

All related docs:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question