Archive: reservfile extraction to certain dir...


reservfile extraction to certain dir...
situation:
ReserveFile "file.ini" extracts file to the uncertain $TEMP subdirectory, now it extracted it to $TEMP\nsy67.tmp\file.ini . But i need it to write a variable afther .oninit to file.ini. So how could i extract it to $TEMP?
i tried in .oninit function
SetOutPath $TEMP
File "${INSTALLER}\file.ini"
, but guess, that it's no use?
could you suggest something? tnx


File "/oname=$TEMP\file.ini" "file.ini"
That's if file.ini is located in the same directory that contains your nsi script.

If file.nsi is elsewhere, say in the NSIS dir, use:
File "/oname=$TEMP\file.ini" "${NSISDIR}\file.ini"

-Stu


ReserveFile does not extract a file.

Can you please give more details about what you are trying to do?


ok...oninit funciton calls function, that writes HD names into variables...Afther that i want to write those variables to ini file(as a state), witch is used in custompage. Those HD names will be used in directory selection on custompage.


Personally, I don't use ReserveFile (I've never used it before).
I simply extract my ini file to the $TEMP dir, then call the dialog straight from there.
I can easily write to it and read from it (WriteINIStr and ReadINIStr) because I know exactly where it is.

-Stu


a part of script that is involved with file.ini
ReserveFile "file.ini"
Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "file.ini"
Call kettad ;detects HD names and puts them inot variables
FunctionEnd
Function SetVinstall
!insertmacro MUI_HEADER_TEXT "" "choose dir"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "file.ini"
FunctionEnd
(in function kettad:
WriteINIStr "file.ini" "Field 4" "State" "${KETAS1}TRPvk-d" ;output is i.e. c:\TRPvk-d)
;custompage function has theese lines:
!insertmacro MUI_INSTALLOPTIONS_READ $4 "file.ini" "Field 4" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $5 "file.ini" "Field 6" "State"
...ok..hope you got what i'm doing
(i got this whole thing working, when i tried to write "${KETAS1}TRPvk-d" into $TEMP\testfile.ini, but not when tried to write in file.ini, that is extracted)


->Afrow UK
ok, but does it do all that ReserveFile MUI_INSTALLOPTIONS_EXTRACT do? or is there some particular reasons to use them?


If you have any File commands in sections above your .onInit function, put ReserveFile above the sections if you are using BZIP2 compression.

It will make your installer start faster, that's all.


1.) i don't use BZIP2 compression(what are the advantages?)
2.) when i used :
SetOutPath $TEMP
File "file.ini"
#loading of custompage failed while trying just file instead of reserve and extract
Function SetVinstall
!insertmacro MUI_HEADER_TEXT "text" "choose dir"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "$TEMP\file.ini"
FunctionEnd


It not using BZIP2 compression, you don't have to use ReserveFile.

Of course, you should still use MUI_INSTALLOPTIONS_EXTRACT (and not $TEMP).


ok, but how to tell installer to extract file to temp dir?


The Modern UI InstallOptions macros automatically use a unique temporary directory.


jeah, that's the problem, that it uses a unique temporary dir in $TEMP directory, but i really need to know where this file is, because i need to write into ini file a variable.
maybe there is a way to detect this dir and put dir into variable, so i know where is this file located during installation, if i don't konw exactly where it is, i can't write anything into it. and if i use this line:
WriteINIStr "file.ini" "Field 4" "State" "${KETAS1}TRPvk-d" ;it CREATES file.ini to the $WINDIR ($WINDIR\file.ini and DOESN'T ADD text to the file.ini in unique temp.dir as i would like) and the text in it is c:\TRPvk-d).
i hope you got my problem.


You should use the MUI_INSTALLOPTIONS_WRITE macro. See the examples & Readme.


tnx:)


Use $PLUGINSDIR


I got another problem with ReserveFile

When I use some files within the same dir as my nsi file it work great! Ex:

ReserveFile "Client.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

.
.
.

Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "Client.ini"
FunctionEnd

For not having all the files in the same dir, I put only the nsi file in the "root" dir and all the other files in "root\Include" dir. Ex:

ReserveFile "Include\Client.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

.
.
.

Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "Include\Client.ini"
FunctionEnd

This is compiling great, but when running it never find the file "$PLUGINSDIR\Client.ini" or $PLUGINSDIR\Include\Client.ini".


Use MUI_INSTALLOPTIONS_EXTRACT_AS (see Modern UI Readme).


Thx It is working perfectly!