简体   繁体   中英

Nsis delete folder & subfolder — inside installer directory

How can i delete intel_xdx folder inside my installer folder. intel_xdx folder have files & subdirectories inside it. This script is not working for me i am not able to delete the intel_xdx folder.

I have even added RequestExecutionLevel admin inside my script.

Installer is for windows 7 PC.

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "uiMagician"
!define PRODUCT_VERSION "1.0.3"
!define PRODUCT_PUBLISHER "Dinesh Guleria"
!define PRODUCT_WEB_SITE "http://www.vscp.org/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\uiMagician.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

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

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "uiMagicianLicence.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$PROGRAMFILES\uiMagician\uiMagician.exe"
!define MUI_FINISHPAGE_SHOWREADME "$PROGRAMFILES\uiMagician\Readme.txt"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "UiMagician_Setup.exe"
RequestExecutionLevel admin
InstallDir "$PROGRAMFILES\uiMagician"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show


Section "MainSection" SEC01
  SetOutPath "$PROGRAMFILES\uiMagician"
  SetOverwrite ifnewer
  File "uiMagicianLicence.txt"
  File "uiMagician.exe"
  CreateDirectory "$SMPROGRAMS\uiMagician"
  CreateShortCut "$SMPROGRAMS\uiMagician\uiMagician.lnk" "$PROGRAMFILES\uiMagician\uiMagician.exe"
  CreateShortCut "$DESKTOP\uiMagician.lnk" "$PROGRAMFILES\uiMagician\uiMagician.exe"
  File "fatbee_v2.ico"
  File "QtXml4.dll"
  File "QtGui4.dll"
  File "QtCore4.dll"
  File "mingwm10.dll"
  File "libgcc_s_dw2-1.dll"
  File "HelpContent.xml"
  File "Readme.txt"
  File "HISTORY.txt"
  File /a /r "intel_xdx\"
SectionEnd

Section -AdditionalIcons
  SetOutPath $INSTDIR
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateShortCut "$SMPROGRAMS\uiMagician\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  CreateShortCut "$SMPROGRAMS\uiMagician\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$PROGRAMFILES\uiMagician\uiMagician.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" "$PROGRAMFILES\uiMagician.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) was successfully removed from your computer."
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
  Delete "$INSTDIR\${PRODUCT_NAME}.url"
  Delete "$INSTDIR\uninst.exe"
  Delete "$PROGRAMFILES\uiMagician\Readme.txt"
  Delete "$PROGRAMFILES\uiMagician\HelpContent.xml"
  Delete "$PROGRAMFILES\uiMagician\libgcc_s_dw2-1.dll"
  Delete "$PROGRAMFILES\uiMagician\mingwm10.dll"
  Delete "$PROGRAMFILES\uiMagician\QtCore4.dll"
  Delete "$PROGRAMFILES\uiMagician\QtGui4.dll"
  Delete "$PROGRAMFILES\uiMagician\QtXml4.dll"
  Delete "$PROGRAMFILES\uiMagician\sample.ico"
  Delete "$PROGRAMFILES\uiMagician\uiMagician.exe"
  Delete "$PROGRAMFILES\uiMagician\uiMagicianLicence.txt"
  Delete "$PROGRAMFILES\uiMagician\fatbee_v2.ico"
  Delete "$PROGRAMFILES\uiMagician\HISTORY.txt"

  RMDir /r "$PROGRAMFILES\intel_xdx\"

  Delete "$SMPROGRAMS\uiMagician\Uninstall.lnk"
  Delete "$SMPROGRAMS\uiMagician\Website.lnk"
  Delete "$DESKTOP\uiMagician.lnk"
  Delete "$SMPROGRAMS\uiMagician\uiMagician.lnk"

  RMDir "$SMPROGRAMS\uiMagician"

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

You're installing intel_xdx into $PROGRAMFILES\\uiMagician\\intel_xdx but you're trying to delete $PROGRAMFILES\\intel_xdx\\ .

Why don't you just delete your program's folder:

RMDir /r "$SMPROGRAMS\uiMagician"

Or even better:

  RMDir /r "$INSTDIR"

Francisco R should've mentioned that using RMDir /r "$INSTDIR" is not safe . From NSIS RMDir documentation :

"Warning: using RMDir /r $INSTDIR in the uninstaller is not safe. Though it is unlikely, the user might select to install to the Program Files folder and so this command will wipe out the entire Program Files folder, including other programs that has nothing to do with the uninstaller. The user can also put other files but the program's files and would expect them to get deleted with the program."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM