CreateProcessWithLogonW access denied

  • Thread starter Thread starter cranedear
  • Start date Start date
C

cranedear

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
question?

Thanks for any help.
 
CraneDear,

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.

http://msdn2.microsoft.com/en-us/library/ms682431.aspx
http://support.microsoft.com/kb/818858

VB 6 Code (easily converted):

http://support.microsoft.com/kb/285879

All related docs:

http://search.microsoft.com/results.aspx?mkt=en-GB&setlang=en-GB&q=CreateProcessWithLogonW
 
Back
Top