Old 21st July 2017, 20:13   #1
blacksec
Junior Member
 
Join Date: Jul 2017
Posts: 3
delete SMPROGRAMS folder

Hello Guys,

I'm trying to delete shortcuts and remove the directory created in SMPROGRAMS but it is don't work.

the $ICONS_GROUP is returning the PROGRAMS folder when it should return the folder defined by the user during instalation.

PS: It's my first post.

follows the code:

code:
; HM NIS Edit Wizard helper defines

!define PRODUCT_NAME "Tryd"
!define PRODUCT_VERSION "5.2.3"
!define PRODUCT_PUBLISHER "Cellbroker"
!define PRODUCT_WEB_SITE "https://MyUrl"
!define LICENCE_URL "https://MyUrl"
;Imagem que é exibida nas boas vindas do instalador após executado
!define VERTICAL_IMAGE "C:\Users\MyUser\vertical_image.bmp"
;!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\trader.exe"
;!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
;!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

; Script generated by the HM NIS Edit Script Wizard.

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "instalador_tryd_multibroker.exe"
BrandingText "Tryd Trading Solutions"
;LoadLanguageFile "C:\Program Files (x86)\NSIS\Contrib\Language files\PortugueseBR.nlf"
InstallDir "C:\Tryd5"
Icon "..\tryd.ico"
;InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
RequestExecutionLevel user
; MUI 1.67 compatible ------
;!include "MUI.nsh" ;MUI1 is no longer avaliable suport.
!include "MUI2.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "..\tryd.ico"
;!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_UNICON "..\tryd.ico"

!define MUI_WELCOMEFINISHPAGE_BITMAP ${VERTICAL_IMAGE}

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Define of function that calls embedhtml plugin
!define MUI_PAGE_CUSTOMFUNCTION_SHOW LicenceShow
; License page
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "..\licdata.txt"
; Directory page
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnLeave
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
!insertmacro MUI_PAGE_DIRECTORY

; Start menu page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER ${PRODUCT_NAME}
;!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
;!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
;!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\trader.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "PortugueseBR"

; MUI end ------

Section "SeçãoPrincipal" SEC01
SetOutPath "$INSTDIR"

File "..\tryd.ico"
File "..\trader.exe"
File "..\trader.ini"
File "..\artifacts.xml"
;File "..\licdata.txt"
File "..\corretora.png"
File "..\corretora_menu_grande.png"
File "..\corretora_menu_medio.png"
File "..\splash.bmp"
File /r "..\jre"
File /r "..\configuration"
File /r "..\suporte"
File /r "..\features"
File /r "..\p2"
File /r "..\plugins"
File /r "..\readme"
File /r "..\workspace"

; Shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Tryd.lnk" "$INSTDIR\trader.exe" "" "$INSTDIR\tryd.ico"
CreateShortCut "$DESKTOP\Tryd.lnk" "$INSTDIR\trader.exe" "" "$INSTDIR\tryd.ico"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

Section -AdditionalIcons
SetOutPath $INSTDIR
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Desinstalar.lnk" "$INSTDIR\desinstalar.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

; Função do plugin EmbedHTML que carrega a página html com a licença de uso do Tryd
Function LicenceShow

FindWindow $R0 `#32770` `` $HWNDPARENT
GetDlgItem $R0 $R0 1000
EmbedHTML::Load /replace $R0 ${LICENCE_URL}

FunctionEnd

; Verificação de existência da pasta Tryd
Function OnLeave

IfFileExists "$InstDir\trader.exe" PathBad PathGood
PathBad:
MessageBox MB_OK "O destino selecionado já existe. Por favor, selecione um outro destino ou apague o existente."
Abort
PathGood:

FunctionEnd

Section -Post
WriteUninstaller "$INSTDIR\desinstalar.exe"
; WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\trader.exe"
; WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
; WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
; WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\trader.exe"
; WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
; WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
; WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) foi removido com sucesso do seu computador."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Tem certeza que quer remover completamente $(^Name) e todos os seus componentes?" IDYES +2
Abort
FunctionEnd

Section Uninstall
;!insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP

Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\desinstalador.exe"
Delete "$INSTDIR\licdata.txt"
Delete "$INSTDIR\artifacts.xml"
Delete "$INSTDIR\CorBmf.txt"
Delete "$INSTDIR\CorBov.txt"
Delete "$INSTDIR\corretora.png"
Delete "$INSTDIR\corretora_menu_grande.png"
Delete "$INSTDIR\corretora_menu_medio.png"
Delete "$INSTDIR\splash.bmp"
Delete "$INSTDIR\trader.exe"
Delete "$INSTDIR\trader.ini"
Delete "$INSTDIR\tryd.ico"

RMDir /r "$INSTDIR\workspace"
RMDir /r "$INSTDIR\suporte"
RMDir /r "$INSTDIR\readme"
RMDir /r "$INSTDIR\plugins"
RMDir /r "$INSTDIR\jre"
RMDir /r "$INSTDIR\configuration"
RMDir /r "$INSTDIR\features"
RMDir /r "$INSTDIR\p2"
RMDir /r "$INSTDIR"

Delete "$SMPROGRAMS\$ICONS_GROUP\Desinstalar.lnk"
Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk"
Delete "$DESKTOP\Tryd.lnk"
Delete "$SMPROGRAMS\$ICONS_GROUP\Tryd.lnk"

RMDir /r "$SMPROGRAMS\$ICONS_GROUP"

;DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
; DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
;SetAutoClose true
SectionEnd

blacksec is offline   Reply With Quote
Old 22nd July 2017, 02:27   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,588
You cannot combine "RequestExecutionLevel user" with HKLM.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th July 2017, 18:47   #3
blacksec
Junior Member
 
Join Date: Jul 2017
Posts: 3
Anders,

Thank you for your attention, but the HKLM lines are commented.

The installer runs without change the windows registry.
blacksec is offline   Reply With Quote
Old 24th July 2017, 19:20   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,588
If you don't define MUI_STARTMENUPAGE_REGISTRY_* then MUI_STARTMENU_GETFOLDER does not work and you manually have to save the folder name in your installer and restore it in the uninstaller before you can delete.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 24th July 2017, 19:51   #5
blacksec
Junior Member
 
Join Date: Jul 2017
Posts: 3
Anders,

You really fast in your responses! Thank you!

That's exactly what I need.

Please, you have a sample or link showing how can I manually save the folder name in installer and restore it in uninstaller?

I believe that this would solve my question.
blacksec is offline   Reply With Quote
Old 24th July 2017, 20:57   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,588
If you want to save it in the registry, just set the MUI_STARTMENUPAGE_REGISTRY_* defines (Use HKCU if you don't force elevation). Use the NSIS Ini functions if you want to save it in a .ini file. MUI_STARTMENU_GETFOLDER only supports the registry, just manually load $ICONS_GROUP if you are using a .ini...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
nsis, rmdir, startmenu, uninstall

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump