Everything works—or at least, no error is generated—but the attribute flags on the installed files in any of the folders are not set to read-only. What am I missing?
; Holocron.nsi
; This script installs the Holocron of Star Wars Galaxies /notepad help files.
;--------------------------------
; Includes
!include "FileFunc.nsh"
!insertmacro Locate
Name "The SWG Holocron" ; The name of the installer
OutFile "Holocron.exe" ; The file to write
InstallDir $INSTDIR ; The default installation directory
InstProgressFlags smooth colored
RequestExecutionLevel user ; Request application privileges for Windows Vista
;--------------------------------
; Pages
Page directory
Page instfiles
;--------------------------------
; Installation tasks
Section ""
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put files there
File /r Holo\*.*
; Set these files to read-only so that
; /notepad can't corrupt them or so they
; don't get changed accidentally.
${Locate} "$INSTDIR\*.*" "/L=F" "SetReadOnly"
SectionEnd
Function .onInit
ReadRegStr $0 HKEY_LOCAL_MACHINE \
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\StarwarsGalaxies" \
"Path"
StrCpy $INSTDIR $0\profiles\Holocron
FunctionEnd
Function SetReadOnly
SetFileAttributes $R9 READONLY
FunctionEnd
Using ${Locate} with SetFileAttributes
I’m fairly new to NSIS, but I’ve managed to get it to do almost everything I want for this little installation script I wrote: