View Single Post
Old 21st July 2017, 21: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