Skip to content
⌘ NSIS Forum Archive

How to ReserveFile in other directory?

5 posts

mergisius#edited

How to ReserveFile in other directory?

Well, the problem is that my *.ini files is in other catalog. Problem is similar to this one http://forums.winamp.com/showthread....ht=ReserveFile, but I don't get how he solved it. If you would do like there "!insertmacro MUI_INSTALLOPTIONS_EXTRACT "installoptions.ini" it wouldn't find it.

My code:

ReserveFile "InstallFields\ServerSettingsPageDB.ini"
ReserveFile "InstallFields\ServerSettingsPageUser.ini"
ReserveFile "InstallFields\ServerSettingsPageDocs.ini"

<.... >

Function .onInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "InstallFields\ServerSettingsPageDB.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "InstallFields\ServerSettingsPageUser.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "InstallFields\ServerSettingsPageDocs.ini"
FunctionEnd

Function SettingsPageDBShow
!insertmacro SectionFlagIsSet ${Server_Recreate} ${SF_SELECTED} 0 end
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "InstallFields\ServerSettingsPageDB.ini"
end:
FunctionEnd

Function ServerSettingsPageDBLeave
!insertmacro MUI_INSTALLOPTIONS_READ $DBSERVER_NAME "InstallFields\ServerSettingsPageDB.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DATABASE_NAME "InstallFields\ServerSettingsPageDB.ini" "Field 5" "State"
FunctionEnd

Function SettingsPageUserShow
!insertmacro SectionFlagIsSet ${Server_Recreate} ${SF_SELECTED} 0 end
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "InstallFields\ServerSettingsPageUser.ini"
end:
<...>
If I wrote "InstallFields\InitFile.ini" in every place where I need to use InitFile.ini, i would get error "Error opening file <..> for writing".

So, how should I corectly reserve a file which is in different directory?
Afrow UK#
According to that code your ini files are in the same folder as your script (MUI_INSTALLOPTIONS_EXTRACT), so what's the problem?

Stu
mergisius#
Originally posted by Afrow UK
According to that code your ini files are in the same folder as your script (MUI_INSTALLOPTIONS_EXTRACT), so what's the problem?

Stu
Well, I edited my code in the post.

Actually, I want to fix that mess with install scripts, so I would like to make folders like "IniFiles", "Scripts", "BatFiles", "Images". That's why i need to reserve files from other directory than my scripts are.
Afrow UK#
ReserveFile will work if the file is there relative to your script.

Your code won't work now as it is. You need to use MUI_INSTALLOPTIONS_EXTRACT_AS.

Stu
mergisius#
Originally posted by Afrow UK
ReserveFile will work if the file is there relative to your script.

Your code won't work now as it is. You need to use MUI_INSTALLOPTIONS_EXTRACT_AS.

Stu
Thank you 🙂


So, now it looks like this and works fine 🙂

!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "IniFiles\ServerSettingsPageDB.ini" "ServerSettingsPageDB.ini"

<...>

!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerSettingsPageDB.ini"