locked
CreateProcessAsUser Error 1314 RRS feed

  • Question

  • Hi

    I am trying to restart explorer from and application of mine, the problem is that the application itself is elevated so on a standard user account when restarting explorer it start under the administrators account showing the administrators desktop files instead of the logged in user. I've been trying to use CreateProcessAsUser as this seems like the only solution that could make it work. I got the user token from the already running explorer.exe, I duplicated it as such:

    DuplicateTokenEx(hToken, TOKEN_ALL_ACCESS, NULL, SecurityImpersonation , TokenPrimary, &hNewToken);
    Then I create the environment block, process and stratupinfo and call CreateProcessAsUser:

    CreateProcessAsUser(hNewToken, NULL,strCommand.GetBuffer(strCommand.GetLength()), NULL,NULL,FALSE, CREATE_NEW_PROCESS_GROUP | CREATE_UNICODE_ENVIRONMENT, lpEnvironment, NULL, &StartUPInfo, &ProcessInfo)
    Where strCommand is a CString that holds "explorer.exe".

    The damn thing doesn't work and by calling GetLastError() I get a 1314 error..... I am not sure what is causing this since the client is running under the administrators privileges.

    Any Ideas...
    Sunday, February 21, 2010 7:20 AM

Answers

  • > I am trying to restart explorer from and application of mine, the
    > problem is that the application itself is elevated so on a standard user
    > account when restarting explorer it start under the administrators
    > account showing the administrators desktop files instead of the logged
    > in user.

    It appears that you can't do it (at least not directly):

    http://blogs.msdn.com/jamesfi/archive/2007/04/11/how-to-launch-an-un-elevated-process-from-an-elevated-process.aspx

    Dave
    • Marked as answer by Nancy Shao Monday, March 1, 2010 6:51 AM
    Sunday, February 21, 2010 10:28 AM

All replies

  • > I am trying to restart explorer from and application of mine, the
    > problem is that the application itself is elevated so on a standard user
    > account when restarting explorer it start under the administrators
    > account showing the administrators desktop files instead of the logged
    > in user. I've been trying to use CreateProcessAsUser as this seems like
    > the only solution that could make it work.

    Have you tried using ShellExecute(Ex) instead?

    Dave
    Sunday, February 21, 2010 9:43 AM
  • The client (Parent) process is elevated so calling shellexecuteex will cause explorer to run under the administrator's profile, this will case the desktop and all explorer settings to run under the administrators profile who executed the client application...

    Not What I'm looking for.... ImpersonateLoggedOnUser will not work also since it will downgrade the client and makes it run under the Standard user privileges..
    Sunday, February 21, 2010 10:10 AM
  • > I am trying to restart explorer from and application of mine, the
    > problem is that the application itself is elevated so on a standard user
    > account when restarting explorer it start under the administrators
    > account showing the administrators desktop files instead of the logged
    > in user.

    It appears that you can't do it (at least not directly):

    http://blogs.msdn.com/jamesfi/archive/2007/04/11/how-to-launch-an-un-elevated-process-from-an-elevated-process.aspx

    Dave
    • Marked as answer by Nancy Shao Monday, March 1, 2010 6:51 AM
    Sunday, February 21, 2010 10:28 AM