【问题标题】:Two .exe versions for different operating systems针对不同操作系统的两个 .exe 版本
【发布时间】:2012-10-24 15:25:46
【问题描述】:

我的基于 NSIS 的安装程序将某个 .exe 文件部署到所有 Windows 平台的目标文件夹中。我们最近发现,如果我们在 Windows 8 上安装,我们需要部署该 .exe 文件的稍微不同的版本。

我们不希望有两个安装程序。 我们宁愿有一个安装程序来“保存”这两个 .exe 文件,并为 windows8 部署正确的一个,为其余文件部署另一个 .exe。

关于我们如何实现这一目标的任何指示?在安装时检测 windows8,当我们检测到它时复制不同版本的 .exe 文件?

谢谢。

【问题讨论】:

    标签: nsis


    【解决方案1】:

    您可以通过包含 NSIS 提供的 LogicLib.nshWinVer.nsh 脚本来非常精确地测试平台。

    这是我在安装应用程序之前进行一些健全性检查时使用的函数:

    Function CheckUnsupportedPlatform
        ${if} ${AtLeastWin95}
        ${AndIf} ${AtMostWinME}
            ;NT4 and W95 use the same version number, we can use ${IsNT} if we need precise identification
            MessageBox MB_OK|MB_ICONEXCLAMATION "Sorry, but your version of Windows is unsupported platform.$\n\
    Supported platforms are currently 2000 / XP / 2003 / Vista / Seven$\n \
                Cannot continue the installation." /SD IDOK
            abort
        ${elseIf} ${isWin2008}
        ${orIf} ${AtLeastWin2008R2}
            MessageBox MB_OK|MB_ICONINFORMATION "Please note that support for Windows 2008 and Windows 8 is in beta stage.$\n\
    Supported platforms are currently 2000 / XP / 2003 / Vista / Seven" /SD IDOK
        ${endif}
    FunctionEnd
    

    还有更多可能,请查看WinVer.nsh 的标题以获取更多示例。

    【讨论】:

      【解决方案2】:

      我在使用 nsis 时遇到了类似的问题,检测到不同的 Windows 版本。我刚刚编写了一个三行 C++ 应用程序来调用 Windows API 以找出操作系统版本,然后将控制台输出写为字符串。从nsis,你可以把这个输出读入一个变量,然后根据这个变量的值进行切换。

      【讨论】:

      • 这似乎有点矫枉过正,因为您可以使用一些已经包含的宏来执行检查。
      【解决方案3】:

      我知道这已经很老了,但如果有人遇到File 命令的问题,这是预期的语法:

      !include "WinVer.nsh"
      ...
      ; The stuff to install
      Section "MyProgram (required)"
          ${If} ${AtMostWin2003}
              File /oname=MyFile.exe "MyFile2003.exe"  
          ${Else}
             File "MyFile.exe"
          ${EndIf} 
      SectionEnd
      

      【讨论】:

        猜你喜欢
        • 2020-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-01
        • 2012-02-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多