I'm attempting to create a lazarus portable 0.9.30, but there is a problem with the PAL Launcher handling the environment variables file the file needs to be copied from the %defaultdata%\settings & %defaultdata%\profile locations, written before the ${AppID}Settings.ini file is overwritten, and then copied tho the desired location. In the PortableApps.comLauncherCustom.nsh file I imputed this code:
${SegmentFile} Var LastAppDir ${DisableSegment} DriveLetter ${Segment.onInit} ${IfNot} ${FileExists} "$EXEDIR\Data" CreateDirectory "$EXEDIR\Data" CopyFiles /Silent "$EXEDIR\App\DefaultData\*" "$EXEDIR\Data" CopyFiles /Silent "$EXEDIR\App\DefaultData\Settings\*" "$EXEDIR\Data\Settings" CopyFiles /Silent "$EXEDIR\App\DefaultData\Profile\*" "$EXEDIR\Data\Profile" ${EndIf} ;=== LastDrive ReadINIStr $LastDrive $EXEDIR\Data\settings\$AppIDSettings.ini $AppIDSettings LastDrive ${GetRoot} $EXEDIR $CurrentDrive ${IfThen} $LastDrive == "" ${|} StrCpy $LastDrive $CurrentDrive ${|} ${DebugMsg} "Current drive is $CurrentDrive, last drive is $LastDrive" ;=== LastAppDir ReadINIStr $LastAppDir "$EXEDIR\Data\Settings\${AppID}Settings.ini" "${AppID}Settings" "LastAppDir" ${If} $LastAppDir == "$EXEDIR\App" ${DebugMsg} "The LastAppDir and the AppDir are the same" ${EndIf} ;=== Sets %PAL:LastAppDir% ${SetEnvironmentVariablesPath} PAL:LastAppDir $LastAppDir ${If} $LastAppDir == "" StrCpy $0 PAL:LastAppDir StrCpy $1 "%PAL:LastAppDir%" System::Call Kernel32::SetEnvironmentVariable(t0,t1) ${EndIf} !macroend ${SegmentPostPrimary} ${GetRoot} $EXEDIR $0 WriteINIStr "$EXEDIR\Data\Settings\${AppID}Settings.ini" "${AppID}Settings" "LastDrive" "$0" WriteINIStr "$EXEDIR\Data\Settings\${AppID}Settings.ini" "${AppID}Settings" "LastAppDir" "$EXEDIR\App" !macroend
and the launcher ini:
[Launch] ProgramExecutable=\lazarus\startlazarus.exe [DirectoriesMove] profile=%LOCALAPPDATA%\lazarus [DirectoriesCleanupIfEmpty] 1=%LOCALAPPDATA%\Lazarus [FilesMove] extra\EnvironmentOptions.xml=%PAL:AppDir%\lazarus [FileWrite1] Type=Replace File=%PAL:DataDir%\settings\EnvironmentOptions.xml Find=%PAL:LastAppDir% Replace=%PAL:AppDir% [FileWrite2] Type=Replace File=%PAL:DataDir%\settings\EnvironmentOptions.xml Find=%PAL:LastDrive% Replace=%PAL:Drive% [FileWrite3] Type=Replace File=%PAL:DataDir%\profile\EnvironmentOptions.xml Find=%PAL:LastAppDir% Replace=%PAL:AppDir% [FileWrite4] Type=Replace File=%PAL:DataDir%\profile\EnvironmentOptions.xml Find=%PAL:LastDrive% Replace=%PAL:Drive%
this disables the drive letter obtaining to obtain and write to this file later, so that the default values can be written to the EnvironmentOptions.xml files, but it does not work as expected it is supposed to replace the value "%PAL:LastAppDir%" and "%PAL:LastDrive%" from the EnvironmentOptions.xml file when first accessed, but this does not work and neither of the two values are changed. It only works after the value is manually changed the first time. Any ideas on what I might have done wrong?
Use PAL 2.1 Beta 2, then you get the partial path support (refer to the release notes). This will do what you want.
I am a Christian and a developer and moderator here.
“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1
thank you I will try that! thank you