安装完成后创建自定义页面 [英] create custom page, after the install is complete

查看:64
本文介绍了安装完成后创建自定义页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个脚本,该脚本正在安装我用电子制作的应用程序,到目前为止,一切似乎都工作正常.但是,有一个问题,我能够添加新的自定义页面,但是它是在安装之前添加的.有一个问题,因为此页面包含两个输入字段,用户必须填写这些输入字段,然后将提供的数据存储在安装了app的目录中.但是由于在此步骤之后安装了应用程序,因此目录将被覆盖并且文件消失了.这是代码:

I am working on a script that is installing my application made in electron and so far all seems to be working fine. There is one problem however, i was able to add new custom page, but it is added before the install is taking place. It is a problem because this page contains two input fields which user must fill and then the provided data is stored in directory where app is installed. But because app is installed after this step, directory gets overwritten and file is gone. This is the code:

!include nsDialogs.nsh
!include LogicLib.nsh

XPStyle on

Var Dialog
Var UserLabel
Var UserText
Var UserState
Var PassLabel
Var PassText
Var PassState

Page custom nsDialogsPage nsDialogsPageLeave

Function nsDialogsPage

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateLabel} 0 0 100% 12u "Username:"
    Pop $UserLabel

    ${NSD_CreateText} 0 13u 100% 12u $UserState
    Pop $UserText

    ${NSD_CreateLabel} 0 39u 100% 12u "Password:"
    Pop $PassLabel

    ${NSD_CreatePassword} 0 52u 100% 12u $PassState
    Pop $PassText

    nsDialogs::Show

FunctionEnd

Function nsDialogsPageLeave

    ${NSD_GetText} $UserText $UserState
    ${NSD_GetText} $PassText $PassState

    ${If} $UserState == ""
        MessageBox MB_OK "Username is missing."
        Abort
    ${EndIf}

    ${If} $PassState == ""
        MessageBox MB_OK "Password is missing."
        Abort
    ${EndIf}

    StrCpy $1 $UserState
    StrCpy $2 $PassState

    FileOpen $9 $INSTDIR\credentials.txt w
    FileWrite $9 "$1:$2"
    FileClose $9
    SetFileAttributes $INSTDIR\credentials.txt HIDDEN|READONLY

FunctionEnd

Section
SectionEnd

所以是的,最好的方法是在安装后而不是之前安装此页面.谢谢您的全方位指导,我是NSIS的新手,所以我不知道如何实现这一目标.

So yes the best would be to have this page after the installation, not before. Thank you for all the directions, i am totally new to NSIS so i have no clue how to accomplish this.

推荐答案

页面的显示顺序与源文件中显示的顺序相同,因此您可以执行以下操作:

Pages are displayed in the same order as they appear in your source file so you can just do:

Page Directory
Page InstFiles
Page Custom MyPage

理想情况下,您应该在安装步骤( InstFiles )之前收集所需的信息,并且您已经快要安装了.您的自定义页面将信息存储在全局变量中,您要做的就是将 File * 操作移至 Section .如果您这样做,那么您的自定义页面可以在 InstFiles 页面之前的任何时间出现.

Ideally you should collect the required information before the installation step (InstFiles) and you are almost there already. Your custom page is storing the information in global variables, all you have to do is to move the File* operations to a Section. If you do it this way then your custom page can appear any time before the InstFiles page.

这篇关于安装完成后创建自定义页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆