- NSIS Discussion
- reservfile extraction to certain dir...
Archive: reservfile extraction to certain dir...
atsuk
13th October 2003 18:07 UTC
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
Afrow UK
13th October 2003 18:44 UTC
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
Joost Verburg
13th October 2003 19:14 UTC
ReserveFile does not extract a file.
Can you please give more details about what you are trying to do?
atsuk
13th October 2003 20:05 UTC
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.
Afrow UK
13th October 2003 20:11 UTC
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
atsuk
13th October 2003 20:15 UTC
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)
atsuk
13th October 2003 20:18 UTC
->Afrow UK
ok, but does it do all that ReserveFile MUI_INSTALLOPTIONS_EXTRACT do? or is there some particular reasons to use them?
Joost Verburg
13th October 2003 20:20 UTC
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.
atsuk
13th October 2003 20:36 UTC
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
Joost Verburg
13th October 2003 20:54 UTC
It not using BZIP2 compression, you don't have to use ReserveFile.
Of course, you should still use MUI_INSTALLOPTIONS_EXTRACT (and not $TEMP).
atsuk
13th October 2003 20:58 UTC
ok, but how to tell installer to extract file to temp dir?
Joost Verburg
13th October 2003 21:24 UTC
The Modern UI InstallOptions macros automatically use a unique temporary directory.
atsuk
14th October 2003 05:44 UTC
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.
Joost Verburg
14th October 2003 13:49 UTC
You should use the MUI_INSTALLOPTIONS_WRITE macro. See the examples & Readme.
atsuk
14th October 2003 20:06 UTC
tnx:)
dëëjayz
27th October 2003 18:26 UTC
Use $PLUGINSDIR
dëëjayz
27th October 2003 19:05 UTC
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".
Joost Verburg
27th October 2003 20:59 UTC
Use MUI_INSTALLOPTIONS_EXTRACT_AS (see Modern UI Readme).
dëëjayz
27th October 2003 21:10 UTC
Thx It is working perfectly!