Old 18th January 2003, 13:40   #1
FreeGeG
Junior Member
 
Join Date: Jan 2003
Posts: 7
Unhappy Variables error

I have tryed for first time to use NSIS * it's rules *

I'm still newbie, and can get the Variable set and Get to work... loog this code and tell whats wrong?

Quote:

LicenseData "${NSISDIR}\Contrib\Modern UI\License.txt"

;Component-selection page
;Descriptions
LangString DESC_SecCopyUI ${LANG_Danish} "Installer Left Alone beta 0.019"

;--------------------------------
;Folder-selection page


EnumRegValue $REGINSTALL HKLM "SOFTWARE\Sierra OnLine\Setup\HALFLIFE" "Directory"
InstallDir "$REGINSTALL"


!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!insertmacro MUI_RESERVEFILE_SPECIALINI
!insertmacro MUI_RESERVEFILE_SPECIALBITMAP

;--------------------------------
;Modern UI System

!insertmacro MUI_SYSTEM

;--------------------------------
;Installer Sections

Section "Left Alone" SecCopyUI
;Add your stuff here
SetOutPath "$INSTDIR"
File "C:\la\test.html"

;--------------------------------
;Create uninstaller

WriteUninstaller "$INSTDIR\Uninstall.exe"

SectionEnd

;--------------------------------
;Descriptions

!insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} $(DESC_SecCopyUI)
!insertmacro MUI_FUNCTIONS_DESCRIPTION_END

;--------------------------------
;Uninstaller Section

Section "Uninstall"

;Add your stuff here

Delete "$INSTDIR"
RMDir "$INSTDIR"

!insertmacro MUI_UNFINISHHEADER

SectionEnd
FreeGeG is offline   Reply With Quote
Old 18th January 2003, 13:57   #2
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
Use ReadRegStr instead of EnumRegValue, since EnumRegValue returns the name of the x'th registry value in a key, not the value of a specified registry value. ReadRegStr does that for strings and ReadRegDWORD for DWORDs.

See also: 3.7.2.11 ReadRegStr.

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Old 18th January 2003, 14:01   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Commands that are not setting installer settings (name, caption, pages, etc.) can not be outside of functions or sections. NSIS must know when to execute the command so it must be in a function or a section.

Also $REGINSTALL is not a NSIS variable. NSIS have only 20 variables available for you to use: $0, $1, $2, ..., $9, $R0, $R1, $R2, ..., $R9 and $INSTDIR, $EXEDIR, etc. which are used for other things.

To set the installation directory according to the registry use InstallDirRegKey (outside of a function or a section because it sets an installer settings which is an automatic installation directory retrival from the registry).

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 18th January 2003, 14:09   #4
FreeGeG
Junior Member
 
Join Date: Jan 2003
Posts: 7
Unhappy

Now it's working thanks
FreeGeG is offline   Reply With Quote
Old 18th January 2003, 14:09   #5
virtlink
Major Dude
 
virtlink's Avatar
 
Join Date: Sep 2002
Location: At [4C69:6E6B]
Posts: 561
kichik still knows more about it than i do. Damn!

"I'll quote you when you say something memorable."
- Claudia Pelsmaeker
virtlink is offline   Reply With Quote
Old 18th January 2003, 14:16   #6
FreeGeG
Junior Member
 
Join Date: Jan 2003
Posts: 7
is there a way to add a dir to the InstallDirRegKey ?
FreeGeG is offline   Reply With Quote
Old 18th January 2003, 14:46   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Edit $INSTDIR in .onInit.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 18th January 2003, 15:14   #8
FreeGeG
Junior Member
 
Join Date: Jan 2003
Posts: 7
Sorry to ask you, but how do i Edit it?
FreeGeG is offline   Reply With Quote
Old 18th January 2003, 15:48   #9
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
For example:

StrCpy $INSTDIR $INSTDIR\MyProg

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 18th January 2003, 21:33   #10
FreeGeG
Junior Member
 
Join Date: Jan 2003
Posts: 7
Aghhh it's working, thanks many times, i have many more questions, but i make a subject there match.
FreeGeG is offline   Reply With Quote
Old 14th August 2003, 12:06   #11
greg9504
Junior Member
 
Join Date: Aug 2003
Location: Ottawa, Ontario, Canada
Posts: 3
Bug in solution?

Hi,

I think there is a bug in the solution. I had

StrCpy $INSTDIR $INSTDIR\MyProg

in my .onInit function. It seemed to work, then something odd started to happen. Instead of seeing

C:\Program Files\mycompany\MyProg

in the directory dialog (modern UI) I was seeing

C:\Program Files\mycompany\MyProg\MyProg\MyProg\MyProg

After a bit of thought I figured it was a copy in place problem and changed the script to:

Function .onInit
StrCpy $0 $INSTDIR\MyProg
StrCpy $INSTDIR $0
FunctionEnd


This seems to have fixed it.

I would like to say what version I am using but can't seem to find that anywhere and can't remember what version I installed. It was 2 something... I most likely took the latest install from a week ago or so, so 2.0 beta 3a.
greg9504 is offline   Reply With Quote
Old 14th August 2003, 12:22   #12
greg9504
Junior Member
 
Join Date: Aug 2003
Location: Ottawa, Ontario, Canada
Posts: 3
Arg! that didn't fix it, well it worked once. Now I am getting

C:\Program Files\MyCompany\MyApp\MyApp

when all I want is

C:\Program Files\MyCompany\MyApp

in the directory dialog. My script looks like:

code:

!define MUI_PRODUCT "MyCompany"
#...
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"
InstallDirRegKey HKCU "Software\${MUI_PRODUCT}" ""
#...
Function .onInit
StrCpy $0 $INSTDIR\MyApp
StrCpy $INSTDIR $0
FunctionEnd



[edited by kichik]Please don't copy and paste huge scripts. Attach them. Irrelevant parts of the script deleted.[/edit]
greg9504 is offline   Reply With Quote
Old 14th August 2003, 12:32   #13
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,433
That is wrong.
You should set $INSTDIR with

InstallDir "C:\program files\blah"

Also, you are using the old NSIS 2.0b3. It is recommended that you download the latest Development version from http://nsis.sourceforge.net
Note that you may have to change a lot in your script (Modern UI has changed a lot too)

-Stu
Afrow UK is offline   Reply With Quote
Old 14th August 2003, 12:57   #14
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
If there is no backslash at the end of InstallDir definition the part after the last backslash will be automatically appended to the user selected directory, if he chose it using the browse button.

If your InstallDir is $PROGRAMFILES\MyCompany and $INSTDIR is $PROGRAMFILES\MyApp in .onInit then its value is probably taken from InstallDirRegKey. Make sure the value is empty before trying again.

You don't need .onInit anyway. Just set InstallDir to be the desired value directly. Example:

InstallDir $PROGRAMFILES\MyCompany\MyApp

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 14th August 2003, 13:20   #15
greg9504
Junior Member
 
Join Date: Aug 2003
Location: Ottawa, Ontario, Canada
Posts: 3
The date on my makensis.exe is 3/17/2003...

Should I be using the latest development build and not the 3abeta release?

Kichik, I tried setting

InstallDir $PROGRAMFILES\MyCompany\MyApp

using:

InstallDir "$PROGRAMFILES\${MUI_PRODUCT}\MyApp"

However in the directory dialog I only saw

"$PROGRAMFILES\${MUI_PRODUCT}"

displayed as the default install dir. However if I chose the default it would install to

"$PROGRAMFILES\${MUI_PRODUCT}\MyApp"

Anyway, you were correct and my repeating problem was due to InstallDirRegKey not being cleaned up.

Thanks.

[on edit]

I just tried setting
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}\MyApp"

and it is working like it should (displayed in directory dialog). I guess it had to due with an old InstallDirRegKey.

Thanks again.
greg9504 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump