zoukankan      html  css  js  c++  java
  • Windows应用安装制作工具调查报告

    Windows应用安装制作工具调查报告

    Windows应用安装方式

    Windows应用安装主要有如下两种方式:

    1. exe:可执行程序executable program,EXE File)
    2. Microsoft Windows Installer( MSI)

    说到MSI文件,不得不先说说Windows Installer,它不只是安装程序,而且是可扩展的软件管理系统。Windows Installer的用途包括:管理软件的安装、管理软件组件的添加和删除、监视文件的复原以及使用回滚技术维护基本的灾难恢复。另外,Windows Installer还支持从多个源位置安装和运行软件,而且可以由想要安装自定义程序的开发人员自定义。要想使用这些功能,就必须通过MSI文件。MSI文件是Windows Installer的数据包,它实际上是一个数据库,包含安装一种产品所需要的信息和在很多安装情形下安装(和卸载)程序所需的指令和数据。MSI文件将程序的组成文件与功能关联起来。此外,它还包含有关安装过程本身的信息:如安装序列、目标文件夹路径、系统依赖项、安装选项和控制安装过程的属性。

    Win8因为UAC的原因,安装MSi文件时会出现2869的错误代码。虽然有解决办法,但因此应该使用exe方式。

    安装制作工具比较

    MSI

    advanced installer

    Microsoft Windows Installer, free 30 days trial
    http://www.advancedinstaller.com/
    Powerful and easy to use Windows Installer authoring tool.
    Install, update and configure your products safely, securely and reliably.

    Excelsior

    "create my installation MSI files which works pretty nicely and there's not a big learning curve at all."

    http://installer.excelsior-usa.com/en/

    Five apps for creating installation packages

    http://www.techrepublic.com/blog/five-apps/five-apps-for-creating-installation-packages/

    1. InstallShield Express 2013: $650 (for the Express edition)
    2. Nullsoft NSIS Installer: price of free for both home and commercial purposes
    You can even take compressed ZIP files and convert them to EXE setups with a basic converter app called Zip2Exe.
    3. InstallAware 16
    4. Advanced Installer: Enterprise edition for a cool $399
    5. Inno Setup: much like Nullsoft's NSIS installer.

    Free Windows Installer Tool

    1. Nullsoft NSIS Installer: price of free for both home and commercial purposes
    You can even take compressed ZIP files and convert them to EXE setups with a basic converter app called Zip2Exe.
    2. WiX
    WiX is an open source collection of tools for generating Windows Installer packages.
    It integrates well with Visual Studio. It works off a set of XML setup declaration files. There is a definite learning curve but there is a book on it and documentation and examples on the Internet. http://wixtoolset.org/

    Installer Features

    完备的安装工具应该具备哪些功能,Refer to InstallShield Features:

    http://www.flexerasoftware.com/producer/products/software-installation/installshield-software-installer/tab/editions

    主要功能如下:

    1. Support for latest Microsoft technologies:win10,win8.x,...
    2. Available in different languages
    3. Create DPI-aware installations
    4. Easily customize your installations
    5. ...

    什么DPI? 全称是dots per inch (DPI), 也就是每英寸的点数,在显示器上就是每英寸的像素个数,Window上一般默认是96 dpi 作为100% 的缩放比率, 但是要注意的是该值未必是真正的显示器物理值, 只是Windows里我们的一个参考标准。XP对高DPI的支持比较差劲, 大部分情况下就是字体的放大。

    Java程序安装基本需求

    1. bat to exe
    2. 压缩和打包
    3. jre
    4. 快捷方式
    5. 卸载
    6. 安装界面的定制
    7. 应用程序log的捕捉

    NSIS (Nullsoft Scriptable Install System)

    NSIS

    Apache Tomcat installer uses NSIS.
    https://sourceforge.net/projects/nsis/
    NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers.
    It is designed to be as small and flexible as possible and is therefore very suitable for internet distribution.

    HM NIS Edit

    https://sourceforge.net/projects/hmne
    HM NIS Edit is the best Editor/IDE for Nullsoft
    Scriptable Install System (NSIS). Its useful for experts and beginner in
    the creation of Setup programs with the NSIS.

    NSIS in Eclipse

    https://sourceforge.net/projects/eclipsensis/?source=recommended

    NSIS脚本制作Java程序的EXE启动器

    http://www.cnblogs.com/zdxster/archive/2011/04/14/2015552.html

    Name "Java Launcher"
    Caption "Java Launcher"
    Icon "Java Launcher.ico"
    OutFile "Java Launcher.exe"
    
    SilentInstall silent
    AutoCloseWindow true
    ShowInstDetails nevershow
    
    Section ""
        Exec "java -jar test.jar"
    SectionEnd
    

    上面这个启动器的一个问题是会打开一个控制台窗口,这是因为用了java命令,只要改为javaw就不会出现控制台了。 另外一个问题是不够健壮,只有当java或者javaw命令在当前目录下或者在PATH上,才能正确启动。也许你想带着一个JRE发布你的程序,那么就不能够去启动系统的java命令。

    下面来加入寻找java命令目录的功能,寻找的顺序为

    1. 当前目录下的jre子目录, 如果你的发布程序里带了一个jre,优先启动。
    2. 环境变量JAVA_HOME 指定的目录
    3. 在注册表中,HKLMSOFTWAREJavaSoftJava Runtime Environment下保存着安装的JRE的目录信息。
    4. 当前目录和系统环境变量PATH中的目录
    Name "Java Launcher"
    Caption "Java Launcher"
    Icon "Java Launcher.ico"
    OutFile "Java Launcher.exe"
     
    SilentInstall silent
    AutoCloseWindow true
    ShowInstDetails nevershow
     
    Section ""
      Call GetJRE
      Pop $R0
     
      ; change for your purpose (-jar etc.)
      StrCpy $0 '"$R0" -jar test.jar'
     
      SetOutPath $EXEDIR
      ExecWait $0
    SectionEnd
     
    Function GetJRE 
      Push $R0
      Push $R1
     
      ClearErrors
      StrCpy $R0 "$EXEDIRjreinjavaw.exe"
      IfFileExists $R0 JreFound
      StrCpy $R0 ""
     
      ClearErrors
      ReadEnvStr $R0 "JAVA_HOME"
      StrCpy $R0 "$R0injavaw.exe"
      IfErrors 0 JreFound
     
      ClearErrors
      ReadRegStr $R1 HKLM "SOFTWAREJavaSoftJava Runtime Environment" "CurrentVersion"
      ReadRegStr $R0 HKLM "SOFTWAREJavaSoftJava Runtime Environment$R1" "JavaHome"
      StrCpy $R0 "$R0injavaw.exe"
     
      IfErrors 0 JreFound
      StrCpy $R0 "javaw.exe"
            
     JreFound:
      Pop $R1
      Exch $R0
    FunctionEnd
    

    NSIS三种压缩方式压缩比对比

    zlib(37.8%), bzip2(35.0%), LZMA(30.2%)

    Using zlib compression.
    
    EXE header size:               60928 / 36864 bytes
    Install code:                  18857 / 63638 bytes
    Install data:               96384144 / 254641558 bytes
    Uninstall code+data:           20906 / 34063 bytes
    CRC (0x593DB559):                  4 / 4 bytes
    
    Total size:                 96484839 / 254776127 bytes (37.8%)
    
    Using bzip2 compression.
    
    EXE header size:               59904 / 35840 bytes
    Install code:                  18567 / 63638 bytes
    Install data:               89185810 / 254641558 bytes
    Uninstall code+data:           20722 / 33994 bytes
    CRC (0x3804E826):                  4 / 4 bytes
    
    Total size:                 89285007 / 254775034 bytes (35.0%)
    
    
    Using lzma compression.
    
    EXE header size:               59392 / 35328 bytes
    Install code:                  15467 / 63638 bytes
    Install data:               76923448 / 254641558 bytes
    Uninstall code+data:           16643 / 31896 bytes
    CRC (0xF22167E9):                  4 / 4 bytes
    
    Total size:                 77014954 / 254772424 bytes (30.2%)
    

    NSIS使用

    NSIS如何设置欢迎界面的标题跟内容的字体和颜色
    http://bbs.hanzify.org/simple/?t93893.html

    NSIS的欢迎页面的图片可以替换成自己定义的吗?
    ------解决方案--------------------
    !define MUI_WELCOMEFINISHPAGE_BITMAP "ddt_prodg.bmp" ;用于欢迎页面和完成页面的位图(推荐尺寸: 164x314 象素).
    !define MUI_UNWELCOMEFINISHPAGE_BITMAP "ddt_prodg.bmp" ;用于卸载页面的位图(推荐尺寸: 164x314 象素).

    MUI 预定义常量
    http://www.cnblogs.com/passingcloudss/archive/2011/10/21/2220663.html
    ; MUI 预定义常量
    !define MUI_ABORTWARNING ;当用户要关闭安装程序时, 显示一个警告消息框
    !define MUI_UNABORTWARNING ;当用户要关闭卸载程序时, 显示一个警告消息框
    !define MUI_ICON "install.ico" ;安装程序图标
    !define MUI_UNICON "uninst.ico" ;卸载程序图标
    !define MUI_FINISHPAGE_NOAUTOCLOSE ;不自动跳到完成页面, 允许用户检查安装记录
    !define MUI_UNFINISHPAGE_NOAUTOCLOSE ;不自动跳到完成页面, 允许用户检查卸载记录
    !define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp" ;用于欢迎页面和完成页面的位图(推荐尺寸: 164x314 象素).
    !define MUI_UNWELCOMEFINISHPAGE_BITMAP "welcome.bmp" ;用于卸载页面的位图(推荐尺寸: 164x314 象素).
    !define MUI_COMPONENTSPAGE_SMALLDESC ;较小的页面底部的描述区域
    !define MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_INFO "鼠标移到组件上可查看相应说明" ;当没有选择区段时, 显示于描述框中的文本

    NSIS后续问题
    1. 怎么看输出log:java-jar ddt3client_lib.jar
    2. 怎么替换安装界面左侧图片: done


    测试
    1. 升级: 新安装升级:done;旧安装升级:done。
    2. jre:无jre的环境装出来能够启动;安装jre1.6的能够启动;

    NSIS trouble shooting

    运行安装后出现用户访问控制提示未知发布者 nsis UAC unknown publisher

    http://stackoverflow.com/questions/10581570/setting-the-uac-publisher-field-for-a-nsis-installer 

    "You would have to Authenticode sign the installer with a certificate authority trusted by windows (If you want to be part of Winqual then you need a special certificate and MS only allows you to useVeriSign) because that field is extracted from the digital certificate (if one exists) and not from the PE version information.

    To sign as part of the build process you can use this hack, or if you are using the Unicode fork then you can use the !finalize command."

    hack: http://nsis.sourceforge.net/Run_Command_After_Compilation

    https://msdn.microsoft.com/en-us/library/bb756995.aspx

    NSIS3: https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0a1/

  • 相关阅读:
    python 练习 10
    python 练习 9
    运算符
    变量类型
    打印更多的变量
    变量和命名
    数字和数字计算
    第一个程序
    python 练习 8
    python 练习 7
  • 原文地址:https://www.cnblogs.com/markjiao/p/5257459.html
Copyright © 2011-2022 走看看