You were misunderstanding the purpose of the CreateProcessAsUser function. This is not an uncommon misunderstanding.
The Win32 functions CreateProcessAsUser, CreateProcessWithLogonW, LogonUser, LogonUserEx, LogonUserExExW, CreateLogonSession, and so on, are all concerned with the kernel's security model (processes, logon sessions and tokens) not with the interactive logon process (creating remote desktop sessions, associating them with a user, and switching between them).
There are no Win32 functions that allow you to control the interactive logon process, although there are functions (such as ExitWindowsEx) that allow you to log the current user off.
Instead, depending on your circumstances, you can register a credential provider or use the AutoAdminLogon registry settings. The former is much more complicated; the latter is more limited - in particular, if the system is logged off, there does not appear to be any reliable way to initiate a logon with new credentials other that rebooting the system.
If you do use AutoAdminLogon, make sure you follow the instructions in Protecting the Automatic Logon Password to keep the password (reasonably) secure.