Old 19th January 2011, 11:20   #1
isawen
Junior Member
 
Join Date: Jan 2010
Posts: 39
Setup with a single command line argument

Hi again,

Probably this is how the actual ${GetOption} command works, but I wanted to be sure.
Let's assume my installer parses the command line arguments passed when executed and it searches for this flag option "/argument1".

code:

ClearErrors
${GetOptions} $cmdLineParams '/argument1' $R0
IfErrors +2 0



If I execute the installer and pass the /argument1234 it detects that /argument1 was passed. Is there a way to avoid this situation?

Thanks,
Isa

isawen is offline   Reply With Quote
Old 19th January 2011, 11:30   #2
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,366
use GetParameters
Yathosho is offline   Reply With Quote
Old 19th January 2011, 11:34   #3
isawen
Junior Member
 
Join Date: Jan 2010
Posts: 39
I'm not sure what do you mean by ${GetParameter}.
I'm using it to get the command line arguments into my $cmdLineParams variable.

isawen is offline   Reply With Quote
Old 19th January 2011, 14:24   #4
820815
Junior Member
 
Join Date: Apr 2009
Location: St. Petersburg, Russia
Posts: 25
use the /argument=1 then StrCmp $R0 1
820815 is offline   Reply With Quote
Old 19th January 2011, 14:30   #5
isawen
Junior Member
 
Join Date: Jan 2010
Posts: 39
That could be a solution but it's more fashion way to have a simple flag (without any value). If this is not possible then I will consider using this.

Thanks,
Isa

isawen is offline   Reply With Quote
Old 19th January 2011, 14:33   #6
isawen
Junior Member
 
Join Date: Jan 2010
Posts: 39
Quote:
Originally Posted by 820815 View Post
use the /argument=1 then StrCmp $R0 1
My flag name is argument1, but that doesn't mean I'm parsing the last 1 from the argument.
Maybe I have choosed a bad name for the argument.

My point is that if you want to have just a flag to be passed as the argument, when you pass as argument a string that begins with your flag the NSIS will consider the flag present it's like the argument you are passing is somehow truncated.

isawen is offline   Reply With Quote
Old 19th January 2011, 14:47   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If you want to match /argument1 exactly then you'll have to also check $R0 is an empty string.

Stu
Afrow UK is offline   Reply With Quote
Old 19th January 2011, 15:12   #8
isawen
Junior Member
 
Join Date: Jan 2010
Posts: 39
Quote:
Originally Posted by Afrow UK View Post
If you want to match /argument1 exactly then you'll have to also check $R0 is an empty string.
Indeed, how come this didn't cross my tired mind.
Again thanks for your help.

isawen 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