Archive: To remove the startmenu folder


To remove the startmenu folder
About the startmenu goup creation I have written:
Var STARTMENU_FOLDER
...
!insertmacro MUI_PAGE_STARTMENU StartMenu $STARTMENU_FOLDER
...
!insertmacro MUI_STARTMENU_WRITE_BEGIN StartMenu
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateShortcut ...
!insertmacro MUI_STARTMENU_WRITE_END
...
Section "Uninstall"
!insertmacro MUI_STARTMENU_GETFOLDER MenuAvvio $0
RmDir "$SMPROGRAMS\$0"
SectionEnd

But it does not work not removing the startmenu group with only 4 links: how to write the code to remove correctly the startmenu group ?
About the startmenu goup creation I have written:
Var STARTMENU_FOLDER
...
!insertmacro MUI_PAGE_STARTMENU StartMenu $STARTMENU_FOLDER
...
!insertmacro MUI_STARTMENU_WRITE_BEGIN StartMenu
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateShortcut ...
!insertmacro MUI_STARTMENU_WRITE_END
...
Section "Uninstall"
!insertmacro MUI_STARTMENU_GETFOLDER MenuAvvio $0
RmDir "$SMPROGRAMS\$0"
SectionEnd

But it does not work not removing the startmenu group with only 4 links: how to write the code to remove correctly the startmenu group ?

Massimo


You need to store the folder it was created in. You could store this value in the registry and then read this to remove the start menu folder during uninstall. Be careful not to remove the entire start menu, though. ;-)


Try this...



Section "Uninstall"
!insertmacro MUI_STARTMENU_GETFOLDER Application $STARTMENU_FOLDER

;You must delete files before deleting folders or it will not work. For example:
Delete "$SMPROGRAMS\$STARTMENU_FOLDER\File_01.lnk"
Delete "$SMPROGRAMS\$STARTMENU_FOLDER\File_02.lnk"

; You also have to delete sub folders if they are there.
RMDir "$SMPROGRAMS\$STARTMENU_FOLDER\Folder_01"

; Now the main folder.
StrCpy $STARTMENU_FOLDER "$SMPROGRAMS\$STARTMENU_FOLDER"

startMenuDeleteLoop:
ClearErrors
RMDir $STARTMENU_FOLDER
GetFullPathName $STARTMENU_FOLDER "$STARTMENU_FOLDER\.."

IfErrors startMenuDeleteLoopDone

StrCmp $STARTMENU_FOLDER $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone:
SectionEnd

The var was declared at the top of your script and called
to be stored as the menu writing application var. You must
start with $ at the first it when calling it.


-MichaelFlya-

Hello,
your code does not work. My code works, using 'rmdir /r ...', only if installing in the main folder startmenu (programs), not in a subfolder.