Nsis 删除文件夹和子文件夹——在安装程序目录中
Nsis delete folder & subfolder -- inside installer directory
如何删除安装程序文件夹中的 intel_xdx
文件夹。 intel_xdx
文件夹中有文件和子目录。此脚本对我不起作用,我无法删除 intel_xdx
文件夹。
我什至在脚本中添加了 RequestExecutionLevel admin
。
安装程序适用于 windows 7 台电脑。
; 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
您正在将 intel_xdx 安装到 $PROGRAMFILES\uiMagician\intel_xdx
,但您正试图删除 $PROGRAMFILES\intel_xdx\
。
为什么不直接删除程序的文件夹:
RMDir /r "$SMPROGRAMS\uiMagician"
甚至更好:
RMDir /r "$INSTDIR"
Francisco R 应该提到使用 RMDir /r "$INSTDIR"
不安全。
来自 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."
如何删除安装程序文件夹中的 intel_xdx
文件夹。 intel_xdx
文件夹中有文件和子目录。此脚本对我不起作用,我无法删除 intel_xdx
文件夹。
我什至在脚本中添加了 RequestExecutionLevel admin
。
安装程序适用于 windows 7 台电脑。
; 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
您正在将 intel_xdx 安装到 $PROGRAMFILES\uiMagician\intel_xdx
,但您正试图删除 $PROGRAMFILES\intel_xdx\
。
为什么不直接删除程序的文件夹:
RMDir /r "$SMPROGRAMS\uiMagician"
甚至更好:
RMDir /r "$INSTDIR"
Francisco R 应该提到使用 RMDir /r "$INSTDIR"
不安全。
来自 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."