Skip to content
⌘ NSIS Forum Archive

ReadRegStr - what's wrong

10 posts

bushpilot#

ReadRegStr - what's wrong

Hello Guys,
i'm new and excuse me for me english, i'm austrian.

I tried for a couple of days and search here in the forum and in the FAQ and in the documents, but i haven't found an solution.

I will install a addon for a Program. The program is existing installed on the pc's from the users. But i don't know, in which location. Under c:\programme oder d
:\program files and so one.

Now i have see the ReadRegStr but i become an error:

Error: command ReadRegStr not valid outside section or function
My lines are here:

ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Microsoft Games\Flight Simulator\9.0" "EXE Path"
StrCpy $0 $INSTDIR ""
In the EXE Path (this is a String) there i will find the correct path to the application.

And in this path i will installe my file, as the same folder structure. Does this go? I have search and tried, but i have no idea what's wrong.

And the next was in my script:
OutFile setup.exe
InstallDir $INSTDIR
.....
SetOutPath "$INSTDIR $0"
File "..\Microsoft Games\Flig
I know, any user will say, i should search in the forum, but believe me, i have search for a long time.

Seeming i'm too stupid.
🙄

I hope everyone can help me.
ParallaxTZ#
Do you have a "Section" in your installer? Many functions only work between "Section" and "SectionEnd".

example:


Section "my program" SEC01
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Microsoft Games\Flight Simulator\9.0" "EXE Path"
StrCpy $INSTDIR $0
SetOutPath "$INSTDIR"
File ""..\Microsoft Games\Flig
.
.
.

SectionEnd
bushpilot#
Yes i have a section. Here are the lines.

; Main Install settings

ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Microsoft Games\Flight Simulator\9.0" "EXE Path"
StrCpy $0 $INSTDIR ""

Name "${APPNAMEANDVERSION}"

InstallDir "$0"
InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "OutFile.exe"

; Modern interface settings
!include "MUI.nsh"

!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "lizenz.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL

Section "Tongass" Section1

; Set Section properties
SetOverwrite on

; Set Section Files and Shortcuts
SetOutPath "$INSTDIR $0"
File "..\Microsoft Games\Flight Simulator 9\Scenery\UTCanada\TFUTback\FSAddon 'Tongass Fjords' UT file backup directory.txt"
File "..\Microsoft Games\Flight Simulator 9\Scenery\UTCanada\TFUTback\TF install - backup of UT files.bat"
File "..\Microsoft Games\Flight Simulator 9\Scenery\UTCanada\TFUTback\TF uninstall - moving back UT files.bat"
CreateShortCut "$DESKTOP\Tongass.lnk" "$INSTDIR\TFUTback\TF install - backup of UT files.bat"
CreateDirectory "$SMPROGRAMS\Tongass"
CreateShortCut "$SMPROGRAMS\Tongass\Tongass.lnk" "$INSTDIR\TFUTback\TF install - backup of UT files.bat"
CreateShortCut "$SMPROGRAMS\Tongass\Uninstall.lnk" "$INSTDIR\uninstall.exe"

SectionEnd
I have this install file create with Venis IX the Free Version.
bushpilot#
Hello,
the error message is now away, i can compile and test, but i can't see the destination Folder.

The installer can't presumably read the string. Hhmm.... i will make a littel screenshot for this string in the registry.

Should you know "Installe Creator" from Clickteam? With this installer that's work, but this installer have no enough functions.
Guest#
Move the following lines into your section:

ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Microsoft Games\Flight Simulator\9.0" "EXE Path"
StrCpy $0 $INSTDIR ""
bushpilot#
Yiippppiiiee, that's it! Wow... it's great.
Many thanks for your help.

I 've sitting about 3 days for this problem... 🧟 but, i think, this was not the only. 😉

Also thanks. What a great helpfully forum.👍