Thanks for the reply,
To avoid repeating SetOutPath would the code look like:
!include LogicLib.nsh
OutFile "installer.exe"
!define SYSTEM32 $SYSDIR
!macro InstallFileTo File
SetOutPath ${SYSTEM32}
File ${File}
!macroend
Section "Install files"
SetOverwrite off
!insertmacro InstallFileTo "FileA.txt"
!insertmacro InstallFileTo "FileB.txt"
!insertmacro InstallFileTo "FileC.txt"
SectionEnd
Also, I would like to keep a record of what files I have put in $SYSDIR, if any.
Would the code look something like:
!include LogicLib.nsh
OutFile "installer.exe"
!define SYSTEM32 $SYSDIR
!macro InstallFileTo File Key
SetOutPath ${SYSTEM32}
File ${File}
WriteRegStr HKLM "Software\CompanyName\CompanyApp\" ${Key} ${File}
!macroend
Section "Install files"
SetOverwrite off
!insertmacro InstallFileTo "FileA.txt" "FileInstalled_1"
!insertmacro InstallFileTo "FileB.txt" "FileInstalled_2"
!insertmacro InstallFileTo "FileC.txt" "FileInstalled_3"
SectionEnd
Section "Uninstall"
...
ReadRegStr $0 HKLM "Software\CompanyName\CompanyApp" "FileInstalled_1"
StrLen $1 $0
${if} $1 > '0'
Delete "${Path}\${File}"
${EndIf}
... FileInstalled_2
... FileInstalled_3
...
SectionEnd
Is this the best way to save something?
I realise there will be some duplicate code in the Uninstall section which is not
desirable. I suppose I would put that in a macro as well.
Is the best solution to put both install/uninstall in a function and then wrap that
with a macro. Therefore, we could call that on install and uninstall.
Cheers,
Paul