Old 7th December 2009, 14:33   #1
pgrasland
Junior Member
 
Join Date: Dec 2009
Posts: 2
Reading command line parameter at runtime

Hello,

I'm trying to use NSIS to do 2 functions with a single installer.

1) Install my program, and stop
2) Update my program, and launch it with a parameter.

I was hoping to do something like that :

setup.exe, without arguments, will install my program and stop
setup.exe parameter, will update (reinstall) my program and launch "program.exe parameter" at the end of the installation.

I don't know how to check a condition in order to launch / don't launch my program, and I don't know how to read a parameter and launch a program with this parameter as argument.

How NSIS can do this ?

Thanks for your help
pgrasland is offline   Reply With Quote
Old 7th December 2009, 14:35   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Re: Reading command line parameter at runtime

Why don't you try searching the forums for 'command line parameters'?
MSG is offline   Reply With Quote
Old 7th December 2009, 15:09   #3
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 304
and search NSIS documentation for 'command line parameters'
Wizou is offline   Reply With Quote
Old 7th December 2009, 15:47   #4
pgrasland
Junior Member
 
Join Date: Dec 2009
Posts: 2
Sorry, I didn't understand how GetParameters / GetOptions worked.

Now, I can see how to detect if it's an update or an install, but how can I pass the parameter value to the program ?

Actually, I'm launching a program with the following lines :

; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\MyApp.exe"
!define MUI_FINISHPAGE_RUN_PARAMETERS "test"
!insertmacro MUI_PAGE_FINISH

I don't know how to use a variable as parameter.
pgrasland is offline   Reply With Quote
Old 7th December 2009, 16:04   #5
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 304
Var myvar

!define MUI_FINISHPAGE_RUN_PARAMETERS "$myvar"

StrCpy myvar "value"
Wizou is offline   Reply With Quote
Old 8th December 2009, 06:16   #6
jdt2oo7
Member
 
Join Date: Oct 2009
Posts: 72
Hi Wizou,

I am also having trouble using variable at runtime. Seem like it has to be a static variable in order for it to work. Below is what I am trying to do, but $Country have to be pre-defined.
Is there anyway it can be variable like how I want it?

Thanks!

===

Var Country

; License page
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "..\doc\${Country}\license.rtf"

Function CountrySelectionLeave
${NSD_LB_GetSelection} $ListBox $0
StrCpy $Country $0
FunctionEnd
jdt2oo7 is offline   Reply With Quote
Old 8th December 2009, 06:58   #7
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Quote:
!insertmacro MUI_PAGE_LICENSE "..\doc\${Country}\license.rtf"
(...)
StrCpy $Country $0
Either it is a variable $Country, or it is a define ${Country}. It's one or the other, you can't have it both ways.
MSG is offline   Reply With Quote
Old 8th December 2009, 07:32   #8
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 304
@jdt2oo7: You can't select the license text file at runtime (except through multilanguage) because NSIS has to know about those files at compile-time in order to compress them inside the installer.
Your problem is more about the display of a text determined at runtime, and I see you have already opened a different forum thread for that.

Be careful with the various way of using $ in NSIS :

${xxx} refers to a !define xxx (constant at compile-time)
$(xxx) refers to a LangString xxx (translation)
$xxx refers to a Var xxx (variable)
$%xxx% refers to a Windows/DOS environment variable (defined at compile-time)
Wizou is offline   Reply With Quote
Old 8th December 2009, 21:09   #9
jdt2oo7
Member
 
Join Date: Oct 2009
Posts: 72
Thanks for your responses, MSG and Wizou!
jdt2oo7 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