I use CreateProcessAsUser to create a process using user credentials.
I post what I hope relates to the relevant parts of the code. Let me know if you want to see anything else.
First LogonUser to get a token:
result = LogonUser( username, wcschr(username, '@') ? NULL : (domain ? domain : L"."), password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hrunastoken);
Then I load the profile, set the lpDesktop value of the STARTUPINFO structure to NULL (which makes it use the desktop of the calling process) and calls CreateProcessAsUser:
result = CreateProcessAsUser( hrunastoken, NULL, apptorun, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, envblock ? envblock : NULL, NULL, &si, &pi);
This works great - it enters the system and successfully creates the process, and the process "works." The problem is that the windows created in it are black, because in this screenshot of the notebook process it started with my program:

Perhaps the appropriate context:
My account is a local account on a computer running Windows 7 with full administrator rights, and I logged in with this account. I used psexec (Sysinternals utility) to open a command prompt that is launched interactively under the local system account. I run my program from this command line. The credentials that I transfer belong to me.
I did not do anything with window / desktop permissions; I assume that the process I create should have rights to those that arise when the process is created in my session, and using the same account with which I have already registered, although I first go through the SYSTEM account. Using Process Explorer, I see no difference in permissions for values ββand processes windowsstation / desktop with a process that is open through my program and does not open normally. Maybe this is completely inappropriate.
I also can not use the CreateProcessWithLogonW function, because it should work when starting from the SYSTEM account - this function, as well as the "runas" program that comes with Windows, do not work under SYSTEM.
Oddly enough, I can not use my current method to open processes if I do not start it under the SYSTEM account, because "the required privilege is not held by the client", so I can not compare the created windows when I run my program under my account and account SYSTEM ...