Hi,everyone!
My problem: I'm trying to get the pathes from txt file. Every line of file is a path. But i wanna to get global pathes from file like this
FileOpen $4 "$DESKTOP\SomeFile.txt" r
FileRead $4 $CurrentGarbage
Push $CurrentGarbage
Delete $CurrentGarbage
Pop $CurrentGarbage
FileClose $4
Where line may be like this $PROGRAMFILES\example\example.txt.
I wanna of my installer to understand, that $PROGRAMFILES is a variable from file, can i do this? I tryied to make it like ${PROGRAMFILES}, all string in quotes, without anything, but it doesn't work.. If i type path C:\Program Files (x86)\example\example.txt - it works. Is there a way to solve my problem?
Path from file
3 posts
Unfortunately you can't read in variables like this at runtime. One way to get around this is to use relative paths in the .txt file, and keep the nsis variables within the script. If you have multiple variables, you might need an identifier in the .txt file so that you know which variable to use, although this can lead to outside processes modifying the .txt for bad purposes so I don't recommend it.
You could try replacing the variables in your string manually:
${StrRep} '$CurrentLine' '$CurrentLine' '$$PROGRAMFILES' '$PROGRAMFILES'
Please notet the double-$ in the the "to be replaced" string, which is required for escaping the $ sign! Otherwise you'd be replacing the current value of $PROGRAMFILES with the current value of $PROGRAMFILES, which is kind of a NOP.
${StrRep} '$CurrentLine' '$CurrentLine' '$$PROGRAMFILES' '$PROGRAMFILES'
Please notet the double-$ in the the "to be replaced" string, which is required for escaping the $ sign! Otherwise you'd be replacing the current value of $PROGRAMFILES with the current value of $PROGRAMFILES, which is kind of a NOP.