简体   繁体   English

Nsis Delete文件夹和子文件夹-安装程序目录中

[英]Nsis delete folder & subfolder — inside installer directory

How can i delete intel_xdx folder inside my installer folder. 如何删除安装程序文件夹中的intel_xdx文件夹。 intel_xdx folder have files & subdirectories inside it. intel_xdx文件夹中包含文件和子目录。 This script is not working for me i am not able to delete the intel_xdx folder. 该脚本对我不起作用,我无法删除intel_xdx文件夹。

I have even added RequestExecutionLevel admin inside my script. 我什至在脚本中添加了RequestExecutionLevel admin

Installer is for windows 7 PC. 安装程序适用于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\\ . 您正在将intel_xdx安装到$PROGRAMFILES\\uiMagician\\intel_xdx但尝试删除$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 . Francisco R应该提到使用RMDir /r "$INSTDIR"不安全的 From NSIS RMDir documentation : NSIS RMDir文档中

"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." “警告:在卸载程序中使用RMDir / r $ INSTDIR是不安全的。尽管这不太可能,但用户可能选择安装到Program Files文件夹,因此此命令将清除整个Program Files文件夹,包括具有与卸载程序无关。用户还可以放置其他文件,但程序的文件除外,并希望它们随程序一起删除。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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