Nullsoft安装程序(NSIS)获取值并保存到文件

Nullsoft安装程序(NSIS)获取值并保存到文件,nsis,Nsis,我正在为特定的tinc vpn安装程序工作。我需要让nullsoft安装程序问我两件事: VPN地址 VPN网络上计算机的名称 这些值将由安装程序写入文本文件(这是后面的步骤) 现在,我正试图弄清楚一旦VAR被放入,如何访问它们 以下是我目前掌握的情况: !include LogicLib.nsh !include nsDialogs.nsh Name nsDialogs OutFile nsDialogs.exe XPStyle on Var Dialog Var Labe

我正在为特定的tinc vpn安装程序工作。我需要让nullsoft安装程序问我两件事:

  • VPN地址
  • VPN网络上计算机的名称
  • 这些值将由安装程序写入文本文件(这是后面的步骤)

    现在,我正试图弄清楚一旦VAR被放入,如何访问它们

    以下是我目前掌握的情况:

     !include LogicLib.nsh
     !include nsDialogs.nsh
    
     Name nsDialogs
     OutFile nsDialogs.exe
    
     XPStyle on
    
     Var Dialog
     Var Label1
     Var Label2
     Var IPAddr
     Var VPNName
    
     Page custom nsDialogsPage nsDialogsPageLeave
     Page instfiles
    
     Function nsDialogsPage
    nsDialogs::Create 1018
    Pop $Dialog
    
    ${If} $Dialog == error
        Abort
    ${EndIf}
    
    ${NSD_CreateLabel} 0 0 100% 12u "What's Your IP Address on the VPN?"
    Pop $Label1
    
    ${NSD_CreateText} 0 12u 100% 12u ""
    Pop $IPAddr
    
    ${NSD_CreateLabel} 0 24u 100% 12u "What's Your IP Address on the VPN?"
    Pop $Label2
    
    ${NSD_CreateText} 0 36u 100% 12u ""
    Pop $VPNName
    
    nsDialogs::Show
    
     FunctionEnd
    
     Function nsDialogsPageLeave
    ${NSD_GetText} $VPNName $0
    DetailPrint "VPN Name: $0"
     Function End
    
     Section
    
     SectionEnd
    

    当然,这在编译器中是失败的。有人知道怎么做吗?我只想做一些简单的事情:提示输入一个文本值,然后将该文本值存储在一个文本文件中,然后将该文件复制到一个指定文件中…

    脚本中有一些语法错误

    你如何编译你的文件?您是否使用一些编辑器-HM NIS编辑、Visual Studio或纯记事本

    在所有情况下,NSIS编译都会告诉您错误在哪里(哪一行)

    下面是固定脚本:

    !include LogicLib.nsh
     !include nsDialogs.nsh
    
     Name nsDialogs
     OutFile nsDialogs.exe
    
     XPStyle on
    
     Var Dialog
     Var Label1
     Var Label2
     Var IPAddr
     Var VPNName
    
     Page custom nsDialogsPage nsDialogsPageLeave
     Page instfiles
    
     Function nsDialogsPage
    nsDialogs::Create 1018
    Pop $Dialog
    
    ${If} $Dialog == error
        Abort
    ${EndIf}
    
    ${NSD_CreateLabel} 0 0 100% 12u "What's Your IP Address on the VPN?"
    Pop $Label1
    
    ${NSD_CreateText} 0 12u 100% 12u ""
    Pop $IPAddr
    
    ${NSD_CreateLabel} 0 24u 100% 12u "What's Your VPN name?"
    Pop $Label2
    
    ${NSD_CreateText} 0 36u 100% 12u ""
    Pop $VPNName
    
    nsDialogs::Show
    
     FunctionEnd
    
     Function nsDialogsPageLeave
    ${NSD_GetText} $VPNName $0
    ${NSD_GetText} $IPAddr $1
    MessageBox MB_OK "VPN Name: $0, IP: $1"
     FunctionEnd
    
     Section main
    
     SectionEnd
    

    使用MessageBox而不是DetailPrint,因为DetailPrint用于将消息添加到安装页面,并且您希望在安装页面尚未初始化时显示某些信息。

    实际上,我确实希望在安装页面上显示信息,而不是消息框。然后记住变量中的信息,稍后再显示,正如我所说的,当安装页面未显示时,您不能使用DetailsPrint。