|
|
|
|
#1 |
|
Junior Member
Join Date: Jun 2009
Posts: 3
|
Installer doesn't delete icons in Start Menu Group
Hello everyone and huge thanks to NSIS community for doing a great job.
The project I'm working in is using NSIS and recently it was found that uninstaller doesn't do it's job correctly. Our installer supports multi user installation mode. The problem is that the uninstaller doesn't delete icons on the desktop and in the start menu group when installing application for the current user. I've found that the reason of it is that $SMPROGRAMS == AllUsers. Here is the code: ... !define PRODUCT_UNINST_ROOT_KEY "SHCTX" !define MULTIUSER_EXECUTIONLEVEL Highest !define MULTIUSER_MUI !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY !insertmacro MULTIUSER_PAGE_INSTALLMODE ... Section Uninstall ... #$SMPROGRAMS points to AllUsers RMDir /r "$SMPROGRAMS\${MANUFACTURER}\${PRODUCT_NAME}$suffix" RMDir "$SMPROGRAMS\${MANUFACTURER}" .. SectionEnd Do I need to set the context of $SMPROGRAMS manually. If yes than how do I get the installation mode used in installer? Can someone help me please? I would appreciate it very much. p.s: sorry for my English, i know it's not perfect
|
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Nov 2005
Posts: 115
|
I'm confused, are you trying to remove the shortcuts during install? The Uninstall section is used for creating the uninstaller (use WriteUninstaller to make the uninstaller .exe, placed in the installer code), uninstall sections aren't executed in the installer. Otherwise you use SetShellVarContext before using $SMPROGRAMS or other shell folders to specify current or all users.
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2009
Posts: 3
|
Thanks for your reply, redxii.
No, I don't try to remove shortcuts during the install process. Section 'Uninstall' is used for the uninstaller. I suppose that when user installs the application, installer writes to registry depending on what install mode has been chosen. It will write to HKLM if install mode is 'all users' or to HKCU is it's only for current user. Then, when uninstaller is executed I suppose it should define how to initialize $SMPROGRAMS by itself. Otherwise, if it doesn't I need to implement some dummy logic like: !if ${ROOT} == 'HKLM' SetShellVarContext all !else if ${ROOT} == 'HKCU' SetShellVarContext current In this case, how do I know the registry root of the installed application? Last edited by headlock; 22nd June 2009 at 08:35. |
|
|
|
|
|
#4 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
The value of $MultiUser.InstallMode will be AllUsers or CurrentUser. I guess we need a SetShellVarContext push and SetShellVarContext pop.
Stu |
|
|
|
|
|
#5 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
I have been thinking about the need for something like this also, it might be a good idea to be able to push/pop all the settings (SetShellVarContext,SetDetailsPrint,SetRegView etc)
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jun 2009
Posts: 3
|
Thanks, Afrow UK! Unfortunetely that didn't help me ...
Here is my code: !define MULTIUSER_EXECUTIONLEVEL Highest !define MULTIUSER_INSTALLMODE_COMMANDLINE #if uncomment this line $MultiUser.InstallMode will always be == 'CurrentUser' #!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "Software\${MANUFACTURER}\${PRODUCT_NAME}$suffix" !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "Install_Dir" !define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCT_NAME}$suffix" !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "Software\${MANUFACTURER}\${PRODUCT_NAME}$suffix" !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "Install_Mode" !define MULTIUSER_MUI ... Section Uninstall ... ${If} $MultiUser.InstallMode == 'AllUsers' SetShellVarContext all ${ElseIf} $MultiUser.InstallMode == 'CurrentUser' SetShellVarContext current ${EndIf} RMDir /r "$SMPROGRAMS\${MANUFACTURER}\${PRODUCT_NAME}$suffix" RMDir "$SMPROGRAMS\${MANUFACTURER}" .. SectionEnd. Perhaps I forgot something to do... |
|
|
|
|
|
#7 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
I think you misunderstand. You just need to SetShellVarContext current before deleting the shortcuts. I posted what I did because you may want to know what to set back with SetShellVarContext afterwards.
Stu |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Apr 2009
Posts: 15
|
Hello, I have a similar problem. I'm not quite following what the solution is though from this thread. Any chance you could go in greater detail.
For me, it's slightly different. Everything in my installer works, except for the uninstalling for the start menu shortcut. The other shortcuts (quciklaunch and desktop) are removed no problem, along with the core of the mod. For reference here is the code I am using (well the bits that are pertinant): code: code: code: code: Now I can't at all figure out what's wrong with that. It installs fine, everything in this script works (even the optional add on stuff I have in other parts of the code), just the danged uninstaller refuses to remove the Start Menu shortcut. (also I replaced the icon stuff and beginning of the uninstall section with a ... because it was running off the screen, and works fine) Anyone have any idea how to fix this? |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Apr 2009
Posts: 15
|
Well I've split the uninstaller into seperate sections, and added:
SetShellVarContext "current" To both the onInit and un.onInit (also tried SetShellVarContext "all"), and still no dice. Anyone have any clue what is wrong with my Uninstaller? Everything works except the blasted Start Menu refuses to be deleted. Here is my unistaller code if that helps: code: I've searched and searched, and been getting help from a programmer who is pretty versed in the NSIS installer on the CivFanatics forums, and no clues come up. It just doesn't work... ![]() Also one thing that might help would be to have a print statement to tell me what exactly the uninstaller is trying to do, that causes it to fail. Is there anyway to set up print statements in NSIS? |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Apr 2009
Posts: 15
|
Well I was able to get logging to work (with some help). The issue is that when you select the folder to install the start menu to, it doesn't relate this information.
$StartMenuFolder should be returning SELECTEDFOLDER/${MOD_LOC}, but instead only returns ${MOD_LOC} I thought this was the whole purpose of MUI_STARTMENU_GETFOLDER Application $StartMenuFolder Anyone know how to get it to pull the selected folder the user chooses when installing? |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Apr 2009
Posts: 15
|
Man this is driving me nuts, I've been hammering away at it all day. My head is about to explode. I can set up another variable, like so:
code: But there seems to be no way to reference it in the uninstaller. Everytime I do, it just comes up blank if I check it. Everything I try I'm just stuck with this in the Install section, with no way to reference it in the uninstall section.... |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Apr 2009
Posts: 15
|
Well I tried a really hacky work around, that I'm not sure how or why it failed. Basically I had it write the Variable to a text file it would create on install. This worked, and the document contained the correct path. Then I set it to read that file in the uninstaller. For some reason if I used a user variable, the script failed to compile. If I used one of the default variables like $R1, it compiled, but there was nothing inside it after it was told to read the file. So strange, I was sure that would work. And it's not like Read and Write code is hard, I can't see what's wrong with it (or why using a user variable would fail to compile, but using a default variable would not). For reference this is what I mean:
code: Above all works, was checked, it wrote the file with the correct path. code: Now the above failed to compile. Complaiend about the FileRead $R4 $HackStartMenu, and said something about the user variable. But the strange thing was using $R2 compiled. But when I checked what was inside of it, it just came out blank. And I did move this to the top of the uninstall functions to make sure the folder wasn't deleted before it had a chance to read it. I think I'm out of ideas now. Help. |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Apr 2009
Posts: 15
|
Got it to work finally. I had to write the StartMenu path to the registry. Now just one minor detail left, but guess I'll start a new thread on it.
|
|
|
|
|
|
#14 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
I was about to go onto what I meant earlier but then I've realised what your problem is. If you'd read the Multi User readme properly you would have saved yourself a lot of hassle.
code: Stu |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Jun 2010
Posts: 9
|
Hi Afrow UK
I'd like to resume this thread, as I've got some problems too. I worked through the Multi User readme, but still don't get it. I'll describe two scenarios, in both of which I am an admin user on XP. 1: Install the application "for anyone using this computer". Shortcuts are created in C:\Documents and Settings\All Users\Startmenu\Programs\MyApp Now I execute the uninstaller and everything (including shortcuts) is removed as expected. 2: Install the application "just for me". Shortcuts are created in C:\Documents and Settings\myUser\Startmenu\Programs\MyApp Now I execute the uninstaller but the shortcuts won't get deleted. The uninstaller tries to remove shortcuts in C:\Documents and Settings\All Users\Startmenu\Programs\MyApp, but there are none. I assume the default "installation mode" in the uninstaller is "AllUsers", if the uninstaller is executed by an admin. I see two solutions:
Is there a simpler solution? Or I am completely of the track? ![]() Thanks, Remo |
|
|
|
|
|
#16 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
The 2nd solution is the correct one (I believe MultiUser will do it for you if you set the correct defines) Or for my take on this: http://www.nsis.pastebin.com/PmiY8DuZ
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#17 | ||
|
Junior Member
Join Date: Oct 2010
Posts: 10
|
I am trying to tailor http://www.nsis.pastebin.com/PmiY8DuZ to install a java app with several .jar libs and a dll. After making the changes I got the nsis compile warning:
Quote:
Quote:
|
||
|
|
|
|
|
#18 | ||
|
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
Quote:
The String Functions header uses Functions for some of its musclework. Functions can't be shared between Installer and Uninstaller, so both are defined when you use ${StrStr} to initialize the functions. If you then subsequently not actually call the uninstaller version of that Function anywhere from the uninstaller, NSIS will throw that warning out there. Unless you really, really need to save a few bytes (those zeroes compress nicely, of course), I wouldn't worry about it. |
||
|
|
|
|
|
#19 | |
|
Junior Member
Join Date: Oct 2010
Posts: 10
|
Uninstaller still does not delete icons in Start Menu Group or from the desktop. Do I need to delete these items explicitly? Do I need to define MUI_FINISHPAGE_RUN? This is the output from the installer followed by a script modified from http://www.nsis.pastebin.com/PmiY8DuZ:
Quote:
PHP Code:
|
|
|
|
|
|
|
#20 |
|
Senior Member
Join Date: Nov 2005
Posts: 115
|
Just off the bat.. since you are using MultiUser for a mixed admin/non-admin install are you checking for the correct context? $SMPrograms will either be the currently logged in user's start menu if SetShellVarContext is set to 'current' (default) and it looks as if you are intending to remove all users' start menu. The same goes for $DESKTOP, its location too will depend on SetShellVarContext.
One way is to check a string in HKCU or HKLM to see which exists, then set un.MultiUser.InstallMode.AllUsers or un.MultiUser.InstallMode.CurrentUser accordingly. You have to check HKLM and HKCU explicitly you can't use SHCTX. Last edited by redxii; 25th October 2010 at 21:44. |
|
|
|
|
|
#21 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
The warning is there because multiuser.nsh wants it, but since its uninstaller handling is broken (IMHO) I use some custom stuff and the function that uses un.StrStr never gets called. I'm guessing you could !define UnStrStr_INCLUDED before including multiuser.nsh and then undef it again.
The normal way to deal with a problem like this is to messagebox the path in the uninstaller and make sure it is correct like redxii suggests. But there is a bigger problem here, why are you using a dual mode script (single and all users) when you are installing files in $sysdir, only admins can do that so normal users will not be able to install without errors! As a final note, adding a desktop shortcut in the startmenu section is well, not kind to your users, just add a desktop shortcut section and a components page IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#22 | ||
|
Junior Member
Join Date: Oct 2010
Posts: 10
|
Ok: back to basics since I need to complete this. I don't need MultiUser or Admin, I was just following the example in http://www.nsis.pastebin.com/PmiY8DuZ hoping to get to a quick solution. I've gone back to something simpler that installs properly but uninstall is only partial. SMPrograms icons are still not being deleted. I have been programming in embedded environments for some time but I am very new to application programming and desktop environments. I am developing on Vista 64 but need to target XP and Vista 32 and 64 installs. I don't need all the bells and whistles in this 1.0 distribution but it would be nice if I could get it to uninstall properly. What is the simplest method to repair the uninstall to include SMPrograms?
Install details: Quote:
Quote:
PHP Code:
|
||
|
|
|
|
|
#23 |
|
Junior Member
Join Date: Oct 2010
Posts: 10
|
Solved: also needed
PHP Code:
|
|
|
|
|
|
#24 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
This issue is a known NT6 problem, see http://nsis.sourceforge.net/Shortcut..._Windows_Vista (Basically, MS broke all old nsis installers)
Using "RequestExecutionLevel highest" is not the correct solution for you since you are installing stuff in $sysdir. Like I said, only admins can do that. Take a look at http://www.nsis.pastebin.com/63tS3AS2 for info on how to make sure your installer runs as admin. Also, it is probably a good idea for you to set "SetShellVarContext all" in BOTH the installer and uninstaller before touching the $smprograms variable. IntOp $PostCount $PostCount + 1 |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|