输出文件名必须为[/"项目名"/"你文件的事名字"]这种形式,否则会报输出文件名非法的提示。
[4]你可能通过outline子窗口,快速定位NSI脚本中的变量与函数。
现在你可以直接把nsi文件拖入Eclipse中编辑了。# All the other settings can be tweaked by editing the !defines at the top of this script !define APPNAME "比价系统" !define COMPANYNAME "浙江天下商邦科技股份有限公司" !define SETUPFILENAME "setup.exe" !define DESCRIPTION "" !define APPEXENAME "cat8637_priceComparingSystem.exe" # These three must be integers # 这里定义的是安装包的版本,应该和当前主程序(EXE文件)的版本一致 !define VERSIONMAJOR 2 !define VERSIONMINOR 0 !define VERSIONBUILD 0 !define VERSIONREVISION 0 #定义当前软件(EXE文件)的版本 !define VERSIONLONG "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.${VERSIONREVISION}" #安装程序ico文件名和位置 !define ICOFILENAME "cat8637_brand2.ico" !define ICOFULLPATH "..\PriceComparingSystem\res\${ICOFILENAME}" # These will be displayed by the "Click here for support information" link in "Add/Remove Programs" # It is possible to use "mailto:" links in here to open the email client !define HELPURL "http://www.8637.com/" # "Support Information" link !define UPDATEURL "http://www.8637.com/" # "Product Updates" link !define ABOUTURL "http://www.8637.com/" # "Publisher" link # This is the size (in kB) of all the files copied into "Program Files" # issue 目录的大小 !define INSTALLSIZE 84379885 RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on) InstallDir "$PROGRAMFILES\${COMPANYNAME}\${APPNAME}" # rtf or txt file - remember if it is txt, it must be in the DOS text format (\r\n) #MUI macro define !define MUI_PAGE_HEADER_TEXT ${COMPANYNAME} !define MUI_PAGE_HEADER_SUBTEXT '${APPNAME} v${VERSIONLONG}' !define MUI_ICON ${ICOFULLPATH} # This will be in the installer/uninstaller's title bar Name "${APPNAME}" Icon "${ICOFULLPATH}" outFile "${SETUPFILENAME}" ;BrandingText '${APPNAME} v${VERSIONLONG}' BrandingText '$0' !include LogicLib.nsh !include nsProcess.nsh #include custom page reference !include "MUI2.nsh" !include "nsDialogs.nsh" !include "kagulaWelcomePage.nsdinc" # Just three pages - license agreement, install location, and installation #!insertmacro MUI_PAGE_WELCOME ;Page custom fnc_kagulaWelcomePage_Show ;page license ;page directory ;Page instfiles !insertmacro MUI_PAGE_LICENSE "license.rtf" !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_LANGUAGE "SimpChinese" !macro VerifyUserIsAdmin UserInfo::GetAccountType pop $0 ${If} $0 != "admin" ;Require admin rights on NT4+ messageBox mb_iconstop "需要管理员权限!" setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED quit ${EndIf} !macroend !include "FileFunc.nsh" Var VersionNumber Function VerCheck pop $0 ;${GetFileVersion} "$INSTDIR\${APPEXENAME}" $VersionNumber ${GetFileVersion} "$0" $VersionNumber FunctionEnd Function VersionCompare !define VersionCompare `!insertmacro VersionCompareCall` !macro VersionCompareCall _VER1 _VER2 _RESULT Push `${_VER1}` Push `${_VER2}` Call VersionCompare Pop ${_RESULT} !macroend Exch $1 Exch Exch $0 Exch Push $2 Push $3 Push $4 Push $5 Push $6 Push $7 begin: StrCpy $2 -1 IntOp $2 $2 + 1 StrCpy $3 $0 1 $2 StrCmp $3 '' +2 StrCmp $3 '.' 0 -3 StrCpy $4 $0 $2 IntOp $2 $2 + 1 StrCpy $0 $0 '' $2 StrCpy $2 -1 IntOp $2 $2 + 1 StrCpy $3 $1 1 $2 StrCmp $3 '' +2 StrCmp $3 '.' 0 -3 StrCpy $5 $1 $2 IntOp $2 $2 + 1 StrCpy $1 $1 '' $2 StrCmp $4$5 '' equal StrCpy $6 -1 IntOp $6 $6 + 1 StrCpy $3 $4 1 $6 StrCmp $3 '0' -2 StrCmp $3 '' 0 +2 StrCpy $4 0 StrCpy $7 -1 IntOp $7 $7 + 1 StrCpy $3 $5 1 $7 StrCmp $3 '0' -2 StrCmp $3 '' 0 +2 StrCpy $5 0 StrCmp $4 0 0 +2 StrCmp $5 0 begin newer2 StrCmp $5 0 newer1 IntCmp $6 $7 0 newer1 newer2 StrCpy $4 '1$4' StrCpy $5 '1$5' IntCmp $4 $5 begin newer2 newer1 equal: StrCpy $0 0 goto end newer1: StrCpy $0 1 goto end newer2: StrCpy $0 2 end: Pop $7 Pop $6 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Exch $0 FunctionEnd function .onInit setShellVarContext all !insertmacro VerifyUserIsAdmin #check program running. ${nsProcess::FindProcess} ${APPEXENAME} $R0 ${If} $R0 == "0" # it's running MessageBox MB_OK "软件正在运行,按确定退出!" Quit ${EndIf} ; MessageBox MB_OK "当前软件的版本为:${VERSIONLONG}" #check version from custom install place ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "MainProgramLocation" ${If} $0 != "" ; MessageBox MB_OK "文件位置:$0" ${If} ${FileExists} $0 ; #if installed version is greater, return 2 ; #else if equality, return 0. ; #else if less, return 1 and resume install process. ; #MessageBox MB_OK "Version=$R0" ; MessageBox MB_OK "before push the parameter for VerCheck function.$0" push $0 Call VerCheck ${VersionCompare} $VersionNumber ${VERSIONLONG} $R0 ${if} $R0 != "1" MessageBox MB_OK "你已经安装同版本或较新版本${APPNAME}软件,按确定退出安装!" Quit ${Endif} ${EndIf} ; ${Else} ; MessageBox MB_ICONSTOP "Not found" ${EndIf} functionEnd section "install" # Files for the install directory - to build the installer, these should be in the same directory as the install script (this file) setOutPath $INSTDIR # Files added here should be removed by the uninstaller (see section "uninstall") File /r "..\issue\" file "${ICOFULLPATH}" # Add any other files for the install directory (license files, app data, etc) here # Uninstaller - See function un.onInit and section "uninstall" for configuration writeUninstaller "$INSTDIR\uninstall.exe" # Start Menu createDirectory "$SMPROGRAMS\${COMPANYNAME}" createShortCut "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" "$INSTDIR\${APPEXENAME}" "" "$INSTDIR\${ICOFILENAME}" # create a shortcut named "new shortcut" in the start menu programs directory # point the new shortcut at the program uninstaller CreateShortCut "$SMPROGRAMS\${COMPANYNAME}\卸载.lnk" "$INSTDIR\uninstall.exe" # Registry information for add/remove programs WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${COMPANYNAME} - ${APPNAME} - ${DESCRIPTION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\${ICOFILENAME}$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "$\"${COMPANYNAME}$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "$\"${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.${VERSIONREVISION}$\"" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR} WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR} # There is no option for modifying or repairing the install WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1 # Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" ${INSTALLSIZE} #Write file install location to register table. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "MainProgramLocation" "$INSTDIR\${APPEXENAME}" sectionEnd # Uninstaller function un.onInit SetShellVarContext all #Verify the uninstaller - last chance to back out MessageBox MB_OKCANCEL "确定要移除 ${APPNAME} 吗?" IDOK next Abort next: !insertmacro VerifyUserIsAdmin functionEnd section "uninstall" # Remove Start Menu launcher delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" delete "$SMPROGRAMS\${COMPANYNAME}\卸载.lnk" # Try to remove the Start Menu folder - this will only happen if it is empty rmDir "$SMPROGRAMS\${COMPANYNAME}" # Remove files delete $INSTDIR\${ICOFILENAME} # Always delete uninstaller as the last action delete $INSTDIR\uninstall.exe # Try to remove the install directory - this will only happen if it is empty rmDir /r $INSTDIR # Remove uninstaller information from the registry DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" sectionEnd
Q5 如何实现高压缩比
SetCompressor lzma
http://www.cnblogs.com/08shiyan/archive/2011/01/10/1931766.html