Archive: Multi user environment shortcut problem


Multi user environment shortcut problem
I am currently installing an app on Windows XP, and installing shortcuts in both All Users and a specifer user, let's say Joe.

SetShellVarContext all
SetOutPath "$INSTDIR\test\bin"
CreateShortCut "$StartMenu\my.lnk" "$INSTDIR\test\bin\my.bat"

that works just fine and all the time for All Users

But then I try this

SetOutPath "$INSTDIR\test\bin"
CreateShortCut "C:\Documents and Settings\Joe\Start Menu\my.lnk" "$INSTDIR\test\bin\my.bat"

I can't seem to get this to work at all. The software pushing this and running the installer has Administration rights.

Any ideas?


CreateShortCut "C:\Documents and Settings\Joe\Start Menu\my.lnk"
This will never work unless the logged user is Joe and Joe has his profile stored in the given path.
Hard coding it's not good idea. Even if you're sure that Joe's profile is in that path, it is possible that Joe's account is protected, so you can't access his profile if the logged user is Bill.
SetShellVarContext takes 2 parameters, the default current, and all. So you may use it like this:
SetShellVarContext all
SetOutPath "$INSTDIR\test\bin"
CreateShortCut "$SMPROGRAMS\my.lnk" "$INSTDIR\test\bin\my.bat"

To create shortcuts for all users and/or some other installation actions,
SetShellVarContext current ; optional
SetOutPath "$INSTDIR\test\bin"
CreateShortCut "$SMPROGRAMS\my.lnk" "$INSTDIR\test\bin\my.bat"

to create shortcuts and/or some other installation actions for the current logged user.

There is no way to install this as Joe. Currently we have a disabled user that we enable, then add to a Administration Group, do an install, then we remove it from that and disable it again.

So during the install, the user doing the install, does have Administration rights and that profile for Joe does exist.


There is no way to install this as Joe
How about impersonating that user (Joe) and running the part of the installer that writes the shortcut, using his security context?
CF

I can't install this as Joe or impersonate him :-)

What I'm going to try now, is a batch solution, if I get that to work, then I may try to create a plugin for NSIS and incorporate that logic.


There is no way to install this as Joe. Currently we have a disabled user that we enable, then add to a Administration Group, do an install, then we remove it from that and disable it again.
There is no way to install this as Joe
???

Is 'Joe' the disabled account or not?

If yes, how about this:
Start the installation as some admin user. Enable Joe + add admin privileges. Then create a token in Joe's sec context and swap to that context, create the shortcut then kill the token (ie revert to the initial admin user), strip Joe's admin privileges, disable him, then go on with the rest of the installation.

I can provide the impersonation part of the code, I have written something similar and works as stated above

CF

Joe is not the disabled account, but the user that ultimately uses the application after reboot.

There is a different disabled account, that gets enabled, receives admin rights, does the install, admin rights are taken away, and the account is disabled, then the computer reboots.


Is Joe an active account? Do you know his password? Can you use something like LogonUser to get a token for Joe then create the shortcut using Joe's security context? Or is it some random account that you need to create a shortcut in its profile folder? If you know the password you can impersonate the user, if not I see the problem :)
CF