Old 20th March 2013, 06:21   #1
miraz.zaidi
Junior Member
 
Join Date: Feb 2013
Posts: 43
Reading from a file at compile time

This may be very simple thing but I couldn't find it anywhere.

I want to read some values from a file (config.json) into some variables when I compile my nsis script.
How can I possibly do that?

Another question is I want to hit a url without opening any browser window, I tried 'execshell ' it did the task but opened the url in default browser window which I dont want. what other options do I have?

Thanks in advance.
miraz.zaidi is offline   Reply With Quote
Old 20th March 2013, 06:43   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
use !system or !execute to run an (NSIS) exe, which reads the file using normal runtime commands and writes to an .nsh file that contains !define Foo "string 1" !define Bar "string 2". Then just !include that .nsh file in your real .nsi.
MSG is offline   Reply With Quote
Old 20th March 2013, 06:58   #3
miraz.zaidi
Junior Member
 
Join Date: Feb 2013
Posts: 43
Thanks. So I must use another exe. That will work. But I wish there was some other way , I really dont want to use an extra exe.
miraz.zaidi is offline   Reply With Quote
Old 20th March 2013, 11:14   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You could even compile a second nsi file into that exe during compilation, to automate everything.
MSG is offline   Reply With Quote
Old 20th March 2013, 12:01   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Use the nsJSON plug-in in a small script (ParseJSON.nsi) which will read the json file and output an nsh file (with !defines):
code:
OutFile ParseJSON.exe
SilentInstall silent
RequestExecutionLevel user

Section
FileOpen $R0 $EXEDIR\Const.nsh w
nsJSON:: ...
FileWrite $R0 '!define ....'
FileClose $R0
SectionEnd

Then you can put this in your main script:
code:
!system `"${NSISDIR}\makensis.exe" ParseJSON.nsi`
!system `ParseJSON.exe`
!system `del ParseJSON.exe`
!include ParseJSON.nsh

Personally I just use an nsh file containing !defines for compile time configuration for basic installers.

Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
compile-time, nsis, url

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