Announcement

Collapse
No announcement yet.

How to create a shortcut in the start menu of another user without this user logging

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create a shortcut in the start menu of another user without this user logging

    Hi,

    I am using window 2k8 R2 server and want to achieve (1) create a user and (2) add a shortcut to the start menu of this new user.

    In more detail, I tried to achieve this flow:

    Step 1: create a new user account;
    Step 2: call LogonUser (windows API) to log on this new user account by impersonating;
    Step 3: get the path to the start menu of this new user;
    Step 4: create and save a shelllink(shortcut) under the start menu path.

    Then the shortcut can start an app when the new user logs in first time.

    Step 3 failed because there is no user folder created for this new user even I have logged on the user account by impersonating.

    So I guess the only way to create the user folders (e.g. document, download, music, pictures, start menu…) is that the user physically logs on by himself for the first time.

    Is there a way to prepare the user folders and put the shortcut into the start menu for this user without the user physically logging on?

    Thanks for any idea.

    Thanks
    Leon

  • #2
    Re: How to create a shortcut in the start menu of another user without this user logg



    I had a look at user profile windows API (http://msdn.microsoft.com/en-us/libr...01(VS.85).aspx). This is my experiment:

    Step 1: Program begins
    Step 2: create a new user
    Step 3: call LogonUser to log on this user
    Step 4: call LoadUserProfile() to load user profile
    Step 5: create a shortcut in this user’s profile folder, verifying the shortcut exists in the user profile folder(succeeded).
    Step 6: call UnloadUserProfile() to unload user profile
    Step 7: program ends.

    Step 8: program begins
    Step 9: LogonUser
    Step 10: load user profile
    Step 11: verify whether the shortcut is still there. – the shortcut is gone.

    As you can see, the change (adding a new shortcut) cannot persist.

    I looked through all API about user profile, finding that only CreateProfile() can update user profile. Is CreateProfile() the right way to just add a shortcut?

    Thanks for your help.


    Leon

    Comment

    Working...
    X