How to read values from a file into textbox and write back from textbox to the same file in NSIS script

172 Views Asked by At

I have to read values from a ini file and put them into some text boxes once user is done with the change he/she can write back these changes to that file. like

[userdetail]
username = "abc"
[personaldetail]
address = äbc.."
work profession = "banker"

NSIS file:

;define textbox  
${NSD_CreateText} 78.33u 5.23u 200.67u 12.31u $Text_State  
Pop $Text


;read value  :
ReadINIStr $Text_State  "C:\ProgramData\testing\test\pnd.ini" "user" "userdetail"
push $Text_State
pop $Text_State

WriteINIStr "$APPDATA\testing\test\pnd.ini" "user" "userdetail" "$Text_State"

Why am I always getting a blank text box value?

1

There are 1 best solutions below

2
On

Why are you using C:\ProgramData folder in ReadINIStr and $APPDATA folder in WriteINIStr ?

$APPDATA is expanded (based on SetShellVar) to C:\Users[User]\AppData\Roaming.

So basically you are reading ad writing to different files.