将输入变量从自定义页面传递到NSIS中的节
下面是我编写的一个程序,它利用了wiki中给定的IpConfig函数。我试图让用户输入文本文件的名称($text),然后用计算机的ipconfig信息填充该文本文件。这可以很容易地在命令提示符下完成,但我的目标是希望它能在NSIS上工作。我能够使用DumpLog转储从detailprints获取的所有数据。此函数生成我需要的.txt文件。我正在努力让用户设置这个.txt文件的名称 我的问题是程序在第一个自定义页面之后结束。我可以输入文件名,但必须点击关闭,程序中止。我曾尝试创建CustomLeave页面,但无法将ipconfig函数与之集成 不幸的是,即使在进一步重构之后,我也可以创建一个没有名称的文本文件,该文件完全填充了所需的数据,这告诉我传递了一个空的“text”name变量 谢谢你的帮助!多谢各位将输入变量从自定义页面传递到NSIS中的节,nsis,Nsis,下面是我编写的一个程序,它利用了wiki中给定的IpConfig函数。我试图让用户输入文本文件的名称($text),然后用计算机的ipconfig信息填充该文本文件。这可以很容易地在命令提示符下完成,但我的目标是希望它能在NSIS上工作。我能够使用DumpLog转储从detailprints获取的所有数据。此函数生成我需要的.txt文件。我正在努力让用户设置这个.txt文件的名称 我的问题是程序在第一个自定义页面之后结束。我可以输入文件名,但必须点击关闭,程序中止。我曾尝试创建CustomLea
!addplugindir "${NSISDIR}\Plugins\x86-unicode"
!addplugindir "${NSISDIR}\Plugins\x86-ansi"
!addplugindir "${NSISDIR}\Plugins"
!include "LogicLib.nsh"
!include "MUI2.nsh"
!include "winMessages.nsh"
!include "nsDialogs.nsh"
!Macro ShowResult ItemString
Pop $0
Pop $1
${if} $0 == "ok"
DetailPrint "${ItemString} $1"
${Else}
DetailPrint "${ItemString} Error: $1"
${EndIf}
!MacroEnd
!Macro ShowMultiResult ItemString
Pop $0
Pop $1
${if} $0 != "ok"
DetailPrint "${ItemString} Error: $1"
${EndIf}
!MacroEnd
;!define LVM_GETITEMCOUNT 0x1004
;!define LVM_GETITEMTEXT 0x102D
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "Some location.bmp"
!define MUI_HEADERIMAGE_RIGHT
!insertmacro MUI_LANGUAGE "English"
OutFile "something.exe"
Page custom custompage
Var dialog
Var Label
Var Text
Var TextBox
Function custompage
!insertmacro MUI_HEADER_TEXT "Something" "Tool"
nsDialogs::Create 1018
Pop $dialog
${NSD_CreateLabel} 0 0 100% 12u "enter text name"
Pop $Label
${NSD_CreateText} 0 12u 93% 12u $Text
Pop $TextBox
nsDialogs::Show
FunctionEnd
Section
DetailPrint "Windows IP-configuration"
DetailPrint ""
IpConfig::GetHostName
!InsertMacro ShowResult " Host Name.......................:"
IpConfig::GetPrimaryDNSSuffix
!InsertMacro ShowResult " Primary DNS Suffix..............:"
IpConfig::GetNodeType
!InsertMacro ShowResult " Node Type.......................:"
IpConfig::IsIPRoutingEnabled
!InsertMacro ShowResult " IP Routing Enabled..............:"
IpConfig::IsWINSProxyEnabled
!InsertMacro ShowResult " WINS Proxy Enabled..............:"
IpConfig::GetDNSSuffixSearchList
!InsertMacro ShowResult " DNS Suffix Search List..........:"
DetailPrint ""
GetFunctionAddress $2 EnabledAdaptersCallback
IpConfig::GetEnabledNetworkAdaptersIDsCB $2
!InsertMacro ShowMultiResult " GetEnabledNetworkAdaptersIDs:"
StrCpy $0 "$Desktop\$Text.txt"
Push $0
Call DumpLog
SectionEnd
复制了下面的DumpLog和IPConfig函数-为清晰起见已删除======================================================================== 首先,把所有的
!脚本开头的addplugindir
说明不是一个好主意,如果调用错误的插件类型,安装程序将崩溃
您的安装程序在第一页之后结束,因为您只有一页
使用DumpLog似乎是毫无意义的工作,如果愿意,您可以直接写入文件
OutFile test.exe
RequestExecutionLevel user
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!insertmacro MUI_PAGE_WELCOME
Page custom custompage custompageleave
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
Var ConfigFile
Var TextBox
Function .onInit
StrCpy $ConfigFile "Text.txt" ; Set default
FunctionEnd
Function custompage
!insertmacro MUI_HEADER_TEXT "Something" "Tool"
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 0 100% 12u "enter text name"
Pop $0
${NSD_CreateText} 0 12u 93% 12u $ConfigFile
Pop $TextBox
nsDialogs::Show
FunctionEnd
Function custompageleave
${NSD_GetText} $TextBox $ConfigFile
FunctionEnd
Section
FileOpen $5 "$Desktop\$ConfigFile" w ; Forcing $Desktop is a bit weird, user should be able to choose a full path?
FileWrite $5 "Hello$\r$\n"
FileWrite $5 "World$\r$\n"
FileClose $5
SectionEnd
如果您想显示输出并保存它,可以使用DumpLog。非常感谢!我只是强迫$Desktop进行自我测试。我已经编辑了我的代码并加入了你的评论,现在它工作得非常完美。感激