Archive: NSIS Newbie: a couple of questions


NSIS Newbie: a couple of questions
Hello,

I'm starting with my first NSIS script, reading docs and looking at examples.

Two questions:

I have something like this:

!define C_VERSION "1.0.0"
!define C_APPNAME "MYTEST"

Var P_ServiceName
Var P_FullName

Function .onInit
ReadEnvStr $P_ServiceName EMS_SERVICEID
StrCpy $P_FullName "${C_APPNAME}_$P_ServiceName"

MessageBox MB_YESNO "This will install $P_FullName. Continue?" IDYES NoAbort
Abort ; causes installer to quit.

NoAbort:
FunctionEnd


The messagebox shows $P_FullName doesn't include the value set for the EMS_SERVICEID environment variable (through $P_ServiceName). Am I missing something?

Another question: is it possible to supply a string as parameter to the install program and have the installer get and use the string for building the default install path name etc?

Thanks a lot,
Mario

1. Are you sure the env string -is- in $P_ServiceName after the ReadEnvStr call? Might want to double-check with a MessageBox.
2. Yes - See the documentation: E.1.11 GetParameters


Originally posted by mabian
The messagebox shows $P_FullName doesn't include the value set for the EMS_SERVICEID environment variable (through $P_ServiceName). Am I missing something?
Try MessageBoxing the return value of your ReadEnvStr command.

Originally posted by mabian
Another question: is it possible to supply a string as parameter to the install program and have the installer get and use the string for building the default install path name etc?
Yes, there is a standard command line parameter for this. I don't know from memory, but I'm sure google can help you there.


Edit: Drats. Foiled again! >_>

Originally posted by Animaether
1. Are you sure the env string -is- in $P_ServiceName after the ReadEnvStr call? Might want to double-check with a MessageBox.
2. Yes - See the documentation: E.1.11 GetParameters
1. Indeed, $P_ServiceName is empty, but why? If I open a command prompt and type SET, the env string is not empty
2. Ok, do I need to do manual parsing of the parameter string?

Thank you!

- Mario

1. No idea - but keep in mind that if you set an evironment variable outside of your installer, your installer may not be aware of that environment variable as it wasn't present when your installer started.

2. The very next bit in the documentation - E.1.12 GetOptions - should help you ;) Depending on what you want to do, there may be some manual parsing of values involved, though.


Ok, dunno about the environment variable, but I needed a way to pass a string to the installer, and getparameters + getoptions made it in a breeze.

Problem solved.

Thank you!

- Mario


oi.. yes, command line parameters are infinitely preferable to environment variables :)