Old 20th October 2011, 20:02   #1
wagner1308
Junior Member
 
Join Date: Oct 2011
Posts: 14
Read an ini file during installation

I am new to nsis

I want the installer read an ini file before starting the installation.
Ini file that will have the following information Name of the installation folder, name for shortcuts among other things.
With this I can have four variations of my applications eg software1.1, software1.2, software1.3, software1.4
And it will not need to have an installer for each application for the changes to the installer will be the destination folder and different shortcuts.
Does anyone have idea how I can do this?

best regards
Wagner.
wagner1308 is offline   Reply With Quote
Old 20th October 2011, 20:11   #2
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Start by reading the documentation:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 21st October 2011, 09:26   #3
wagner1308
Junior Member
 
Join Date: Oct 2011
Posts: 14
I believe that right did not explain what I do.
This is how I have a product installer, the installer will with an ini file. When running the installer will read the ini file and picked up some information, such as the installation folder and more.
reading the documentation I saw the property ReadINIStr
eg ReadINIStr $ 0 $ INSTDIR \ winamp winamp.ini outname
But my problem is I'm not keeping a fixed place, where is the ini file.
I have to make the installer look for an ini file when it runs and if he does not have the ini file to install a default installation of the product?

I remember that my product has many Ex versions: Standard, Professional

I know I'm not sure I could explain what I do.
But thanks to which I responded
wagner1308 is offline   Reply With Quote
Old 21st October 2011, 09:50   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
1) You can use FindFirst/FindNext to find all .ini files in a certain directory. http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.5.12
2) You can use ReadIniStr to read from an ini file.
3) To set the default installation directory, simply do the following in the .onInit function: StrCpy $INSTDIR "C:\Your\Path"

With this information, you should be able to figure out how to do it.
MSG is offline   Reply With Quote
Old 21st October 2011, 11:15   #5
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Does it really have to be that complicated?

Why not put the INI file into the same folder as the "Setup.exe", e.g. as "Setup.ini".

You could then simply read from the "$EXEDIR\Setup.ini" file...


Though I would think about a different option:

Instead of using an INI file to read the info at install-time, you can use Macros and set the info a compile-time!

This way you still had to compile a different installer EXE for each product, but it could be done in a 100% automated way.

The info that differs between different products could simply be passed to MaskeNSIS.exe via CLI parameters...

(Not more work than creating an INI file for each product and no runtime dependency on the INI file)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 21st October 2011, 16:08   #6
wagner1308
Junior Member
 
Join Date: Oct 2011
Posts: 14
that was what I was looking for, you think your place in the ini file "$EXEDIR" will be possible for me to copy the imformation I need.
The matter of this macro I do not quite understand, I have little knowledge of nsis.
Well, I'll try to use the "$EXEDIR" with ReadIniStr. If I have problems I'll post here.
Thank you friends
wagner1308 is offline   Reply With Quote
Old 21st October 2011, 16:23   #7
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Normally you would use something like this to create shortcuts:

CreateDirectory "$SMPROGRAMS\My Company"
CreateShortCut "$SMPROGRAMS\My Company\My Program.lnk" "$INSTDIR\My Program.exe"



With Macros you could replace the hardcoded strings like this:

CreateDirectory "$SMPROGRAMS\${CompanyName}"
CreateShortCut "$SMPROGRAMS\${CompanyName}\${ProgramName}.lnk" "$INSTDIR\My Program.exe"



These would then be defined at the top of your NSI file like:

!define CompanyName "My Company"
!define ProgramName "My Program"



Either that, or you pass them directly to the NSIS compiler as arguments:

makensis.exe "/DCompanyName=My Company" "/DProgramName=My Program" Installer.nsi


In the latter case, it would be advisable to add checks like this to your NSI file:

!ifndef CompanyName
!error "CompanyName is undefined!"
!endif

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 21st October 2011, 18:39   #8
wagner1308
Junior Member
 
Join Date: Oct 2011
Posts: 14
my friends
Can you make more or less what it wanted.
Using $EXEDIR with ReadINIStr.

But I'm not happy because my idea was to generate a single installer and when it is executed with an ini file the installer would get the information MenuGroup shortcut name and then I would just burn a CD with an installer and an ini file. if no ini file it installs the product with the settings that are already defined in the installer.
Now so I could do with using $EXEDIR ReadINIStr I'll have to change the installer to insert five ini files:
are: Standard, Professional, Professional Plus, Advanced, Special

How could I fix it?

Thank you!
wagner1308 is offline   Reply With Quote
Old 21st October 2011, 19:24   #9
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Fix what?

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 21st October 2011, 19:50   #10
msroboto
Junior Member
 
Join Date: Sep 2006
Posts: 47
How about you create one installer and 5 zip files that contain the right .ini file?
Standard.zip Professional.zip etc.

They download the right installer however you do that they unzip and you read the right .ini file. Alternatively, you create one installer that requires the .ini and you mail them the .ini or have some other way to get it.
Same idea they have to have the setup.exe and the .ini in the same directory.

None of these methods is foolproof. The .ini can be easily traded for sure.
msroboto is offline   Reply With Quote
Old 24th October 2011, 10:25   #11
wagner1308
Junior Member
 
Join Date: Oct 2011
Posts: 14
the installer can read a file, where I do not have to specify the file path or put the file in EXEDIR.
The installer could read at the level where it is? the local directory?, so I could check if the file exists then read ini settings and picks.
If there is no ini file then installs with pre-existing settings.
Thanks for the help everyone.
wagner1308 is offline   Reply With Quote
Old 24th October 2011, 12:11   #12
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
What do you mean with 'the local directory'?
MSG is offline   Reply With Quote
Old 24th October 2011, 12:16   #13
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quote:
Originally Posted by wagner1308 View Post
the installer can read a file, where I do not have to specify the file path or put the file in EXEDIR.
The installer could read at the level where it is? the local directory?, so I could check if the file exists then read ini settings and picks.
If there is no ini file then installs with pre-existing settings.
$EXEDIR refers to the directory where the installer executable (e.g. Setup.exe) is located. This is determined at run-time. Read "$EXEDIR\Setup.ini" and you will be reading the "Setup.ini" that is located in the very same directory where the "Setup.exe" is located, regardless of what directory that is. You can of course check for the existence of "$EXEDIR\Setup.ini" before you do that.

Was that your question?

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 25th October 2011, 09:36   #14
wagner1308
Junior Member
 
Join Date: Oct 2011
Posts: 14
this explanation was that I lacked it worked, did not understand.
Thank you friends
wagner1308 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump