CyberSpace
10th February 2002 01:58 UTC
Problem with a directory
I comes from German and my English is not so good.
I have taken the example1.nsi with only a little modification. Here is the problem:
; example1.nsi
;
; This script is perhaps one of the simplest NSIs you can make. All of the
; optional settings are left to their default settings. The instalelr simply
; prompts the user asking them where to install, and drops of notepad.exe
; there. If your Windows directory is not C:\windows, change it below.
;
; The name of the installer
Name "Example1"
; The file to write
OutFile "example1.exe"
StrCpy $1 C:\Program Files\ICQ
; The default installation directory
InstallDir $1
; The text to prompt the user to enter a directory
DirText "This will install the very simple example1 on your computer. Choose a directory"
; The stuff to install
Section "ThisNameIsIgnoredSoWhyBother?"
; Set output path to the installation directory.
SetOutPath $1
; Put file there
File "C:\windows\notepad.exe"
SectionEnd ; end the section
; eof
ok, I will Install a ICQ Plugin to the directory C:\Program Files\ICQ but I will not use the variable $PROGRAMFILES
And here the Error when I compile it:
Processing script file: "example1.nsi"
Name: "Example1"
OutFile: "example1.exe"
StrCpy $1 "C:\Program" (Files\ICQ) ()
Error: Can't add entry, no section or function is open!
Error in script "example1.nsi" on line 14 -- aborting creation process
The Big Problem is this here:
StrCpy $1 "C:\Program" (Files\ICQ) ()
normal the line should look like this:
StrCpy $1 "C:\Program Files\ICQ) ()
thx for help
0mar
10th February 2002 03:07 UTC
Hey CyberSpace. :)
Your English is fine, but you have more than just a directory problem. ;)
First of all, the compiler is failing because you have a StrCpy instruction outside of a section. You can't mix instructions in with installer attribute definitions - instructions like StrCpy can only be used in Sections or Functions.
Secondly, any path that has spaces must be enclosed in quotes, e.g. "C:\Program Files"
I have modified the script you posted so that it 'works' and puts notepad.exe in C:\Progam Files\ICQ... You really ought to disable directory selection if you don't want the end user to choose the destination directory.
Anyway, I hope the changes I have made are evident to you - I defined INSTALLPATH to allow you to easily change the path, quoted the path, and that's pretty much it.
I strongly suggest you read the NSIS documentation (NSIS\makensis.htm & NSIS\functions.htm) very carefully, and go through the examples line by line and see how they work. It's very straightforward after you make that initial investment. :)
Good luck. :up:
!define INSTALLPATH "C:\Program Files\ICQ"
; The name of the installer
Name "Example1"
; The file to write
OutFile "example1.exe"
; The default installation directory
InstallDir "${INSTALLPATH}"
; The text to prompt the user to enter a directory
DirText "This will install the very simple example1 on your computer. Choose a directory"
; The stuff to install
Section "test"
; Set output path to the installation directory.
SetOutPath "${INSTALLPATH}"
; Put file there
File "C:\windows\notepad.exe"
SectionEnd ; end the section
; eof
CyberSpace
10th February 2002 05:18 UTC
Yup, it works fine :) thx.
0mar
10th February 2002 20:54 UTC
You're quite welcome CyberSpace. :)
A small suggestion - I'm not sure if this example is just for learning or you intend to use it. If it's for learning, that's great. :) If you intend to use it, I would suggest you change the following line:
SetOutPath "${INSTALLPATH}"
to this:
SetOutPath "$INSTDIR"
That way the installer will actually use the directory selected by the user... ;)
Anyway, take care. :)