【问题标题】:How to bundle exe file inside another exe file using nsis script如何使用 nsis 脚本将 exe 文件捆绑到另一个 exe 文件中
【发布时间】:2016-12-19 13:20:20
【问题描述】:

我有一个名为 sample.exe 的安装程序文件。这个 exe 文件将包含一些必须定义的组件,例如端口号、安装目录等。我必须将此 sample.exe 文件捆绑在另一个名为 test.exe 的安装程序中。因此,当我尝试安装 test.exe 时,它​​也应该安装 sample.exe。我可以看到在 nsis 中有实现此目的的选项,但是如何在安装 test.exe 时提供用于输入端口、sample.exe 目录路径的选项?我是 nsis 的初学者,任何参考都是示例脚本,对我有很大帮助。提前致谢。

【问题讨论】:

    标签: windows windows-installer installation nsis


    【解决方案1】:

    您需要在输入这些值的位置创建自定义(安装程序)页面

    为此使用 nsDialogs(推荐):http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html

    由于您的规范非常模糊,因此没有确切的解决方案,而是检查示例并使用其中提供的代码 sn-ps。

    【讨论】:

      【解决方案2】:

      您一般使用目录页面让用户选择安装目录。使用nsDialogs插件可以在自定义页面上记录非标准用户输入:

      Name "Foo"
      OutFile "TestSetup.exe"
      RequestExecutionLevel admin
      InstallDir "$ProgramFiles\Test"
      !define DEFAULTPORT 666
      
      !include nsDialogs.nsh
      
      Var MyPort
      Var PortEdit
      
      Function .onInit
      StrCpy $MyPort "${DEFAULTPORT}"
      FunctionEnd
      
      Page Directory
      Page Custom MyPageCreate MyPageLeave
      Page InstFiles
      
      
      Function MyPageCreate
      nsDialogs::Create 1018
      Pop $0
      
      ${NSD_CreateLabel} 0u 10% 20u 12u "Port: "
      Pop $0
      
      ${NSD_CreateNumber} 20u 10% 40u 12u "$MyPort"
      Pop $PortEdit
      
      nsDialogs::Show
      FunctionEnd
      
      Function MyPageLeave
      ${NSD_GetText} $PortEdit $MyPort
      FunctionEnd
      
      Section
      SetOutPath $InstDir
      File "Sample.exe"
      
      ; Write the chosen port to a config file:
      WriteIniStr "$InstDir\Config.ini" "Network" "Port" "$MyPort"
      SectionEnd
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-01-31
        • 1970-01-01
        • 2018-09-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-10
        相关资源
        最近更新 更多