Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use variable on NSIS include / to get another variable

Tags:

nsis

Is there anyway to include file by mention it with variable? I mean

StrCpy $1 "bla.nsh"
!include $1

?

or maybe getting value of variable that called by another variable such as:

StrCpy $1 "EN"
StrCpy $2 ${LANG_${1}_WELCOME_MESSAGE}

?

Thanks.

like image 765
user2269104 Avatar asked Aug 18 '13 17:08

user2269104


People also ask

How to set environment variable in NSIS?

If you want to set an environment variable only for the installer process and its sub-processes use: System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("name", "value").

How to compile NSIS script?

To compile you can right-click your . nsi file and select Compile NSIS Script. This will cause MakeNSISW, the NSIS Compiler Interface, to launch and call MakeNSIS to compile your script.

What is a NSIS script?

Nullsoft Scriptable Install System (NSIS) is a script-driven installer authoring tool for Microsoft Windows backed by Nullsoft, the creators of Winamp. NSIS is released under a combination of free software licenses, primarily the zlib license.


2 Answers

Variables can only be used at runtime (running on the end-users machine), you need to use defines:

!define foo "bar"
!include "${foo}.nsh"

Edit:

You should be using the LangString instruction if you want to add custom translated strings, you can access a langstring at runtime with $(mystringid).

like image 82
Anders Avatar answered Sep 18 '22 17:09

Anders


Actually, Anders right. Think about that, when the compiler compiling your code, it need to know which files it need to include with your EXE file.

About the variable, you can use only with defines. again, because when you are compiling, the compiler will compile all the needed (in use) variables / defines, and you can't tell him use one that never been declared.. its little different from server side languages because here you are compiling and pack your code into EXE file which is assembled in your computer.

like image 32
Idan Gozlan Avatar answered Sep 21 '22 17:09

Idan Gozlan