Archive: Remove shortcuts issue


Remove shortcuts issue
Hello,

I'm stucked with a remove shortcuts issue:

If user A installs MyApp and user B removes it, I end up with user A having all shortcuts on his desktop and start menu undeleted. Any ideea how to fix this problem ?

Thanks,
Radu Ban


SetShellVarContext all


Thanks for your reply.

But what happens if both users A and B are power users?
AFAIK, setting SetShellVarContext all will work only for administrative accounts.
Also, deleting the links for "all" setting will delete it only if it was installed in the "All Users" path ...

The only solution I come up is to save the $DESKTOP and $SMPROGRAMS used for installation in the registry under the uninstaller keys and to use them on uninstall instead of $DESKTOP and $SMPROGRAMS.

Thanks,
Radu Ban


Using SetShellVarContext all automatically sets $SMPROGRAMS to the "All Users" path.


Yes, but the settings for user A are saved in the user A profile not in the "All Users" path. The uninstaller will try to remove the settings from "All Users" and not remove the settings from user A profile ...

Thanks,
Radu Ban


In this situation you should put the shortcuts in the "All Users" dir. B has probably no rights to delete A's files.


;try this

;in the installer

ReadEnvStr $1 USERNAME

;reads the username

WriteIniStr $INSTDIR\settings.ini
Common User "$1"

;writes it to the ini file




Section Uninstall
ReadIniStr $1 $INSTDIR\settings.ini Common "User"
ReadEnvStr $2 USERNAME

Strcmp "$1" "$2" "" "leave_uninst"
here goes the real uninstal stuff


:leave_uninst
MessageBox MB_OK "The program was installed by $1 and can only be uninstalled with this User. Please Login as $1 and start uninstaller"
abort
SectionEnd

this is the only way i know to know both account names and compare them

hope it helps


As I wrote, users A and B are both Power Users. User A can't install in the "All Users" profile because it has no administrative privileges. In this case the app will be invisible for user B since all the shortcuts are on user's A profile. However, the uninstall will be visible in the control panel, so if B removes it(and it can because it's also an Power User) is preferable to do a clean uninstall.


Originally posted by flizebogen
;try this

;in the installer

ReadEnvStr $1 USERNAME

;reads the username

WriteIniStr $INSTDIR\settings.ini
Common User "$1"

;writes it to the ini file




Section Uninstall
ReadIniStr $1 $INSTDIR\settings.ini Common "User"
ReadEnvStr $2 USERNAME

Strcmp "$1" "$2" "" "leave_uninst"
here goes the real uninstal stuff


:leave_uninst
MessageBox MB_OK "The program was installed by $1 and can only be uninstalled with this User. Please Login as $1 and start uninstaller"
abort
SectionEnd

this is the only way i know to know both account names and compare them

hope it helps
Thanks for your reply. In the end I solved the problem by saving the $DESKTOP and $SMPROGRAMS in the registry
under the uninstall key on install and read them back on uninstall so user B can do a clean remove. I have no intention to forbid user B to remove the application if he wants it - but I want an clean uninstall.

Thanks,
Radu Ban

i don't understand

the uninstall section residents in HKLM but the normal user has no write permission to this key AFAIK. And in addition user A can not access the documents and settings folder of user b. I know there a exceptions but assumed that both users are USERS than a clean uninstall should fail


You can also write the uninstall key in HKCU instead of HKLM. That way user B will not see it in his Add/Remove control panel.