NSIS学习笔记

NSIS想出笔记

Date:2015-05-20

Author:kagula

Env:VS2013Update4、、、eclipse-jee-kepler-SR2-win32、Win7-64bits

NSIS境况设置
第一步:(波湾阴谋NSIS本子)

从网站下载发送和勃起的。

STEP2:(NSIS本子的词句)
涉及文献[ 3 ]的Eclipse勃起的NSIS可插件,用于波湾阴谋NSIS本子。
【月食 main 卡特尔>扶助>勃起的 new software…]->type the nsis http address and select component to 勃起的。
上面是你必要睬的零件
[ 1 ]伊柯丽斯 NSIS可插件不支持或高高的版本。Windows8或高高的版本不支持。
[ 2 ]不得不率先构造东西空签订拟定草案,之后添加NSIS经过辅助的 本子将民族语言误审。误审音讯是空的。。
经过添加勃起的[ 3 ]辅助的 调动球员发送(INI)发送

输入发送名不得不为签订拟定草案据以取名/你的发送的名字T,抑或将企图输入发送名法律不许可的心情。。

【4】你可以经过轮廓的子窗口,在NSI本子斋戒面向的变量和功用。

现时你可以把NSI发送到Eclipse汇编者。

最新版本(突然转向版本)可以直的从FO下载。

https://github.com/henrikor2/eclipsensis

STEP3:(自界说交流)
涉及[ 1 ]下载.exe,咱们必要从勃起的交流的界说中如愿以偿即将到来的器。。

即将到来的议事顺序很简略。
第一步:基本的写在eclipsensis本子(或以此类推NSIS本子汇编者器)
次要的脚步:启动NSIS compiler。【NSIS 卡特尔>波湾阴谋器>波湾阴谋器 NSI 本子]。
第三步:以NSI发送,拖NSIS 在波湾阴谋,NSIS 波湾阴谋器自动地波湾阴谋,的行进。

应用NSIS不得不率先学会应用本子语言,每当事人代表东西NSIS本子命令,源发送的扩展名是叫NSI,头发送的扩展名是。NSH。

东西软件可以由多个子群结合,NSIS采用分得的财产代表每个子群。示例行为准则列举如下:
Section “My Program”
SetOutPath $INSTDIR
File “My Program.exe”
File “”
SectionEnd

这是东西典型的例行为准则NSIS,不计自界说呼叫风骨,他们做成某事些许人曾经在那里。

# All the other settings can be 调理 by editing the !defines at the top of this script
!define APPNAME       "奇偶性体系"
!define COMPANYNAME   鞭打浙江州科技股份有限公司
!define SETUPFILENAME ""
!define DESCRIPTION   ""

!define APPEXENAME    ""

# These three must be integers
# 这是勃起的包的版本。,它理应与最近的的主顺序版本划一(EXE FI
!define VERSIONMAJOR    2
!define VERSIONMINOR    0
!define VERSIONBUILD    0
!define VERSIONREVISION 0

界说最近的的软件版本(exe发送)
!define VERSIONLONG  "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.${VERSIONREVISION}"

勃起的顺序图标发送名和所在地
!define ICOFILENAME ""
!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   "" # "Support Information" link
!define UPDATEURL "" # "Product Updates" link
!define ABOUTURL  "" # "Publisher" link

# This is the size (在 KB) of all the files copied into "Program Files"
# issue 目录簿的上胶料
!define INSTALLSIZE 84379885
 
RequestExecutionLevel admin ;Require admin rights on NT6+ (当 UAC is turned 对)
  
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 ""
!include ""
!include ""
 
# 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 ""
!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 ""
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 运转。
    ${nsProcess::FindProcess} ${APPEXENAME} $R0
    ${If} $R0 == "0"
        # it''s running
        MessageBox MB_OK 软件运转,单击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 议事顺序。
;        #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 你曾经勃起的了相等的数量版本或恢复版本的$ { }软件修正,单击OK辞职勃起的!"
           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 (这 发送)
    setOutPath $INSTDIR
    
    # Files added here should be removed by the uninstaller (见 section 卸下)
    File /r "..\issue\"
    file "${ICOFULLPATH}"
    # Add any other files for the install directory (发许可证 files, app data, 等) here
 
    # Uninstaller - See function un.onInit and section "uninstall" for configuration
    writeUninstaller "$INSTDIR\"
 
    # 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\"
 
    # 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\$\""
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\$\" /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 本子) 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 表。
    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\
 
    # 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

FQA:
Q1、国文成绩
涉及材料[1]里的nsis-3.0b1-是不支持国文的,不得不下载。
源发送被设置为UTF-8编码典型。
用上面的行为准则与试验有关的
CreateShortCut “$SMPROGRAMS\国文与试验有关的.lnk” “$INSTDIR\”
MessageBox MB_OK  “国文与试验有关的” 
是可以常态显示国文的。

涉及上面的行为准则段,把勃起的交流弄成国文
!include “”
………………
!insertmacro MUI_LANGUAGE “SimpChinese”

Q2、以任何方式与试验有关的曾经运转的行动?
答:采用4脚步。
第一步:下载
次要的脚步:遮盖NSIS Unicode勃起的目录簿树
第三步:可插件目录簿做成某事最近的发送到可插件目录簿并列命名。
四个步:上面的行为准则可以修正决定因素
${nsProcess::FindProcess} “” $R0
${If} $R0 == “0”
# it”s running
MessageBox MB_OK 顺序曾经运转,单击OK辞职!”
Quit
${EndIf}

Q3、以任何方式应用nsisdialogdesigner
A1:
应用nsisdialogdesigner行进发送
在首要的NSI发送在您的,把呼叫命令的零件,添加以下行为准则
!include “”
!include “”
!include “”

Page custom fnc_kagulaWelcomePage_Show
你将显示东西自界说呼叫,但你会见它在钢骨构架内。

Q4、向前现代字体 User 与移交的区别使联系拟定草案
发许可证显示呼叫,应用以下命令行
LicenseData “”
page license
梅艳芳办法应用以下命令。
!insertmacro MUI_PAGE_LICENSE “”

Q5 以任何方式如愿以偿高减速比

SetCompressor LZMA算法

Q6 NSIS 打包 win7 不克不及拟出快捷方式

决定因素材料

【1】NSIS Dialog Designer

【2】NSIS home page

[ 3 ]伊柯丽斯 NSIS

[4]Auto-uninstall old before installing new

【5】NSIS FAQ 初学者想出男仆涉及

[ 6 ] unicode NSIS误审民族语言称nsprocess可插件

【7】NSIS detection of a 32-bit process in Win 7 64

【8】NSIS Modern User Interface

[ 9 ]专用化 an 在 NSIS MUI2 page

[ 10 ] A sample script that uses several cool functions (代表 txt, mutually exclusive functions, MUI, patch install, etc.)

(代表_txt,_mutually_exclusive_functions,_MUI,_patch_install,_etc.)

【11】NSIS 自界说勃起的交流为INS赢得使筋疲力尽的receive 接收

[ 12 ]分贝 数据库地址和路排列功用

勃起的[ 13 ] NSIS软件达到结尾的添加行为准则来设置的交流

发表评论

电子邮件地址不会被公开。 必填项已用*标注