Archive: Newbie Question - Dynamically change OutFile


Newbie Question - Dynamically change OutFile
Hello,

I am trying to create a generic installer. We have a lot of projects that needs to be installed, so I am hoping to write on template installer that can read in the following information Dyanmically

- Name
- OutFile
- InstallDir

I am new to NSIS. So I tried many different ways to change the values for these variables in .onInit and in Section. But I guess these variables can be declared in Functions nor Sections.

Any advice will be great!

Thanks!

Justin


This might help you, but we'd need some more info on where the data comes from.

http://nsis.sourceforge.net/archive/...instances=0,44

Code in Sections and Functions are only executed on run-time, so it isn't possible to set the OutFile for example, on run-time (because it has to be called on compile-time to create the installer in the first place!)

-Stu


Thanks Stu for the prompt reply

I just tested the example that you showed it. However, since Version.txt is am empty text file, part 2 wont compile. If I run part 1, which will create some text in Version.txt, part 2 is compiled the text in Version.txt. If I update the version for MyFile.exe, it will be showing the compiled version instead of the updated version.

I want to change the Name, InstallDir, etc. by changing some text file (txt, ini, etc.). I want to make a generic installer that will pull in the info from the text without having to compile everytime.

Thanks!

Justin


(I appologize up front if this is too wordy, but hopfully, it will make a bit of sense...)

All you should need to do is modify the first install (GetVersion.EXE) to read the name, outfile, and installdir values from either a txt or ini file and then write it back out as a header file.

Your main script then calls 2 things:


!system "GetVersion.exe"
!include "Version.txt"


The !system command tells the compiler to execute GetVersion.EXE, which then creates "Version.txt". (Version.txt would then include name, outfile, and installdir.) The !include then includes version.txt as a part of the main script.

Since name and outfile are both compile-time commands, you'll still have to compile your main script each time to incorporate them. But, you'd still have the flexibility of being able to simply modify a text file and then create a new install.

And MakeNSIS can be command-line driven, so if you still wanted to automate the compile process, you could. (See Chapter 3 of the NSIS help manual for details about MakeNSIS usage.)

Hope this helps. :)