Thanks again Anders.
Ok, so I don't need the installer to create an xml file.
The program itself will create settings.xml with all the default values - on first run on clean installs.
I just need to check and adjust that one existing setting on upgrades.
The following are already declared/defined in the main nsi script so aren't required for this section:
Here's what I've got so far
I've also tried the following variations:
There can't be anything like /?id= after the service url.
Was it just an example to show how an edit should work?
The installer compiles and runs properly.
The settings dir and file (in %AppData%) are not read-only.
The folder has full write permissions etc.
Everything works, except...when I go to the Settings folder,
settings.xml has not been modified and the old custom value for <my service=""/> still exists.
I'm not sure what I'm doing wrong.
Ok, so I don't need the installer to create an xml file.
The program itself will create settings.xml with all the default values - on first run on clean installs.
I just need to check and adjust that one existing setting on upgrades.
The following are already declared/defined in the main nsi script so aren't required for this section:
code:
Unicode True
RequestExecutionLevel Admin
!include "LogicLib.nsh"
Var SETTINGSDIR
!define FILES_PATH
Here's what I've got so far
PHP Code:
Section "name3"
SetOutPath $INSTDIR\Bin
File ${FILES_PATH}\Bin\some.dll
File ${FILES_PATH}\Bin\another.dll
WriteRegStr HKEY_CLASSES_ROOT "foo" "" "blah"
; If it exists, backup current component settings file first
${If} ${FileExists} "$SETTINGSDIR\path\to\name3\settings.xml"
CreateDirectory "$SETTINGSDIR\path\to\name3\backup"
CopyFiles /SILENT "$SETTINGSDIR\path\to\name3\settings.xml" "$SETTINGSDIR\path\to\name3\backup\settings.xml"
; Force using new default service on upgrades
nsisXML::create
nsisXML::load "$SETTINGSDIR\path\to\name3\settings.xml"
${If} $0 P<> 0
nsisXML::select '/program/my'
${If} $1 P<> 0
nsisXML::setAttribute "service" ""
nsisXML::save "$SETTINGSDIR\path\to\name3\settings.xml"
${EndIf}
nsisXML::release $0
${Else}
nsisXML::release $1
${EndIf}
${EndIf}
SectionEnd
code:
nsisXML::select '/program:settings/my'
I've also tried adding your extra lines:code:
nsisXML::setAttribute "service" "http://mynewsite.com/service2/"
Although I'm not sure what this does tbph.code:
System::Call 'KERNEL32::GetTickCount()i.r5' ; Get arbitrary value in $5
nsisXML::setAttribute "url" "http://mynewsite.com/service2/?id=$5"
There can't be anything like /?id= after the service url.
Was it just an example to show how an edit should work?
The installer compiles and runs properly.
The settings dir and file (in %AppData%) are not read-only.
The folder has full write permissions etc.
Everything works, except...when I go to the Settings folder,
settings.xml has not been modified and the old custom value for <my service=""/> still exists.
I'm not sure what I'm doing wrong.
Comment