之前公司用nsis打包安装程序,nsis可算小巧但功能很强大的打包工具,值得推荐! nsis fro delphi ; Script generated by the HM NIS Edit Script Wizard.; HM NIS Edit Wizard helper defines!define PRODUCT_NAME "*****管理系统"!define PRODUCT_VERSION "0.1.0"!define PRODUCT_PUBLISHER "上海*****有限公司"!define PRODUCT_WEB_SITE "http://www.*****.com/"!define PRODUCT_UNINST_KEY "Software/${PRODUCT_PUBLISHER}/${PRODUCT_NAME}"!define PRODUCT_UNINST_ROOT_KEY "HKLM"SetCompressor lzma!include "AddToPath.nsh"; MUI 1.67 compatible ------!include "MUI.nsh"; MUI Settings!define MUI_ABORTWARNING!define MUI_ICON "${NSISDIR}/Contrib/Graphics/Icons/modern-install.ico"!define MUI_UNICON "${NSISDIR}/Contrib/Graphics/Icons/modern-uninstall.ico"; Welcome page!insertmacro MUI_PAGE_WELCOME; Directory page!insertmacro MUI_PAGE_DIRECTORY; Instfiles page!insertmacro MUI_PAGE_INSTFILES; Finish page!insertmacro MUI_PAGE_FINISH; Uninstaller pages!insertmacro MUI_UNPAGE_INSTFILES; Language files!insertmacro MUI_LANGUAGE "SimpChinese"; Reserve files!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS; MUI end ------Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"OutFile "服务器-${PRODUCT_VERSION}.exe"InstallDir "C:/Inetpub/scripts"ShowInstDetails showShowUnInstDetails showSection "MainSection" SEC01 SetOutPath "$SYSDIR" File "sc.exe" ExecWait "$SYSDIR/sc.exe stop w3svc" SetOutPath "$INSTDIR" File /r dist/*.* ExecWait "$SYSDIR/sc.exe start w3svc"SectionEndSection -AdditionalIcons CreateDirectory "$SMPROGRAMS/${PRODUCT_NAME}" CreateShortCut "$SMPROGRAMS/${PRODUCT_NAME}/卸载.lnk" "$INSTDIR/uninst.exe"SectionEndSection -Post WriteUninstaller "$INSTDIR/uninst.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}" "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}" Push $INSTDIR Call AddToPathSectionEndFunction .onInit ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" StrCmp $R0 "" done MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION / "您的系统中已安装 ${PRODUCT_NAME},请点 确定 卸载,点 取消 退出!" / IDOK uninst Abort;Run the uninstalleruninst: ClearErrors ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file IfErrors no_remove_uninstaller done ;You can either use Delete /REBOOTOK in the uninstaller or add some code ;here to remove the uninstaller. Use a registry key to check ;whether the user has chosen to uninstall. If you are using an uninstaller ;components page, make sure all sections are uninstalled. no_remove_uninstaller: Abortdone:FunctionEndFunction un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"FunctionEndFunction un.onInit MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 $(^Name) ,其及所有的组件?" IDYES +2 AbortFunctionEndSection Uninstall ExecWait "$SYSDIR/sc.exe stop w3svc" Delete "$INSTDIR/SoaServices/*.*" Delete "$INSTDIR/ServiceProviders/*.*" Delete "$INSTDIR/*.bpl" Delete "$INSTDIR/uninst.exe" Delete "$INSTDIR/LebutSoaServerD7.dll" Delete "$SMPROGRAMS/${PRODUCT_NAME}/卸载.lnk" RMDir "$SMPROGRAMS/${PRODUCT_NAME}" RMDir "$INSTDIR/SoaServices" RMDir "$INSTDIR/ServiceProviders" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SetAutoClose true ExecWait "$SYSDIR/sc.exe start w3svc"SectionEnd nsis for net ; Script generated by the HM NIS Edit Script Wizard.; HM NIS Edit Wizard helper defines; !define PRODUCT_NAME "*****管理系统"; !define PRODUCT_VERSION "0.1.0"; !define MAIN_EXE "SCDNS.exe"!define PRODUCT_PUBLISHER "上海*****有限公司"!define PRODUCT_WEB_SITE "http://www.lebut.com/"!define PRODUCT_DIR_REGKEY "Software/Microsoft/Windows/CurrentVersion/App Paths/${MAIN_EXE}"!define PRODUCT_UNINST_KEY "Software/${PRODUCT_PUBLISHER}/${PRODUCT_NAME}"!define PRODUCT_UNINST_ROOT_KEY "HKLM"SetCompressor lzma!include "LogicLib.nsh"!include "DotNET.nsh"!define DOTNET_VERSION "2.0.50727"; MUI 1.67 compatible ------!include "MUI.nsh"; MUI Settings!define MUI_ABORTWARNING!define MUI_ICON "${NSISDIR}/Contrib/Graphics/Icons/modern-install.ico"!define MUI_UNICON "${NSISDIR}/Contrib/Graphics/Icons/modern-uninstall.ico"; Welcome page!insertmacro MUI_PAGE_WELCOME; Directory page!insertmacro MUI_PAGE_DIRECTORY; Instfiles page!insertmacro MUI_PAGE_INSTFILES; Finish page!define MUI_FINISHPAGE_RUN "$INSTDIR/${MAIN_EXE}"!insertmacro MUI_PAGE_FINISH; Uninstaller pages!insertmacro MUI_UNPAGE_INSTFILES; Language files!insertmacro MUI_LANGUAGE "SimpChinese"; Reserve files!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS; MUI end ------Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"OutFile "客户端-${PRODUCT_VERSION}.exe"InstallDir "$PROGRAMFILES/${PRODUCT_NAME}"InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""ShowInstDetails showShowUnInstDetails showSection "MainSection" SEC01 !insertmacro CheckDotNET SetOutPath "$INSTDIR" File /r dist-client/*.* CreateDirectory "$SMPROGRAMS/${PRODUCT_NAME}" CreateShortCut "$SMPROGRAMS/${PRODUCT_NAME}/${PRODUCT_NAME}.lnk" "$INSTDIR/${MAIN_EXE}" CreateShortCut "$SMPROGRAMS/${PRODUCT_NAME}/在线更新.lnk" "$INSTDIR/LiveUpdate.exe" CreateShortCut "$STARTMENU/${PRODUCT_NAME} - 在线更新.lnk" "$INSTDIR/LiveUpdate.exe" CreateShortCut "$SMSTARTUP/${PRODUCT_NAME} - 在线更新.lnk" "$INSTDIR/LiveUpdate.exe" CreateShortCut "$DESKTOP/${PRODUCT_NAME}.lnk" "$INSTDIR/${MAIN_EXE}"SectionEndSection -AdditionalIcons CreateShortCut "$SMPROGRAMS/${PRODUCT_NAME}/卸载.lnk" "$INSTDIR/uninst.exe"SectionEndSection -Post WriteUninstaller "$INSTDIR/uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR/${MAIN_EXE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "InstallDirectory" "$INSTDIR" 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/${MAIN_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}"SectionEndFunction .onInit ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" StrCmp $R0 "" done MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION / "您的系统中已安装 ${PRODUCT_NAME},请点 确定 卸载,点 取消 退出!" / IDOK uninst Abort;Run the uninstalleruninst: ClearErrors ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file IfErrors no_remove_uninstaller done ;You can either use Delete /REBOOTOK in the uninstaller or add some code ;here to remove the uninstaller. Use a registry key to check ;whether the user has chosen to uninstall. If you are using an uninstaller ;components page, make sure all sections are uninstalled. no_remove_uninstaller: Abortdone:FunctionEndFunction un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 已成功地从您的计算机移除。"FunctionEndFunction un.onInit MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "您确实要完全移除 $(^Name) ,其及所有的组件?" IDYES +2 AbortFunctionEndSection Uninstall Delete "$INSTDIR/Actions/*.*" Delete "$INSTDIR/ServiceProviders/*.*" Delete "$INSTDIR/Templates/*.*" Delete "$INSTDIR/DownloadTemp/*.*" Delete "$INSTDIR/*.exe" Delete "$INSTDIR/*.dll" Delete "$INSTDIR/*.config" Delete "$INSTDIR/*.bmp" Delete "$SMPROGRAMS/${PRODUCT_NAME}/卸载.lnk" Delete "$DESKTOP/${PRODUCT_NAME}.lnk" Delete "$SMPROGRAMS/${PRODUCT_NAME}/${PRODUCT_NAME}.lnk" Delete "$SMPROGRAMS/${PRODUCT_NAME}/在线更新.lnk" Delete "$STARTMENU/${PRODUCT_NAME} - 在线更新.lnk" Delete "$SMSTARTUP/${PRODUCT_NAME} - 在线更新.lnk" RMDir "$SMPROGRAMS/${PRODUCT_NAME}" RMDir "$INSTDIR/DownloadTemp" RMDir "$INSTDIR/Templates" RMDir "$INSTDIR/ServiceProviders" RMDir "$INSTDIR/Actions" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" SetAutoClose trueSectionEnd