A call to CreateProcessAsUser will fail with ERROR_INVALID_PARAMETER if your new process belongs to another session and you allowed inheritance of handles. In this case you have to set parameter bInheritHandles to FALSE.