PDA

View Full Version : GetParameters error


goldy1064
21st April 2006, 16:50
I have a problem with GetOptions on East Asian language OS's, but only when running from the desktop. I'm checking for a command-line switch (-cd) in order to do a semi-silent temporary install and then launch the application. However, when run from the desktop on Chinese (Traditional and Simplified) and Japanese, it detects this option. I used a messagebox and saw that after calling GetParameters, my variables was set to *. Any help would be much appreciated.

Thanks,

Instructor
22nd April 2006, 08:05
goldy1064 can you produce some code? It can be unicode problem or something else.

Afrow UK
22nd April 2006, 18:49
I think this could be an issue with StrCpy. A lot of functions on the Wiki (Archive back in the day) failed because as soon as they'd hit a unicode character they'd return "" and so the functions would think they were at the end of the string and exit the loops. We had to change it to a character count vs position.

-Stu

goldy1064
24th April 2006, 16:09
Well, I had recently changed my code to use this instead of the old GetParameters function that use to be in the NSIS help and that worked fine. I guess that I will switch back to what I had previous. Thanks.

Afrow UK
24th April 2006, 16:27
The GetParameters function in the NSIS manual used to have this issue but was later updated.

-Stu

goldy1064
24th April 2006, 17:09
Whatever version I had taken, I guess was correct. I'm not sure why the FileFunc GetParameters would have a problem, though, since I thought it was based from the GetParameters that use to be in the help.

Instructor
24th April 2006, 17:49
goldy1064 what command line? What returns ${GetParameters}? What returns sunjammer's "GetParameters"?

goldy1064
24th April 2006, 18:29
I use the following function to determine whether or not this will be a full install. If the -cd option is detected, I don't write any registry keys and I remove all files after reboot.
Here's what I currently do:

...
Function .onInit
...
Call IsTempInstall
...
FunctionEnd

Function IsTempInstall
Push $R0
Push $R1

${GetParameters} $R0
ClearErrors
${GetOptions} $R0 -cd $R1
${If} ${Errors}
StrCpy $TempInstall 0
${Else}
StrCpy $TempInstall 1
MessageBox MB_OK "-cd detected"
${EndIf}

Pop $R1
Pop $R0
FunctionEnd


Here's what I use to do (with the GetParameters function that I was using from the help):

Function IsTempInstall
Push $R0
Push $R1

Call GetParameters
Pop $R0
${If} $R0 == "-cd"
StrCpy $TempInstall 1
${Else}
StrCpy $TempInstall 0
${EndIf}

Pop $R1
Pop $R0
FunctionEnd

Function GetParameters
Push $R0
Push $R1
Push $R2
Push $R3

StrCpy $R2 1
StrLen $R3 $CMDLINE

;Check for quote or space
StrCpy $R0 $CMDLINE $R2
StrCmp $R0 '"' 0 +3
StrCpy $R1 '"'
Goto loop
StrCpy $R1 " "

loop:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 get
StrCmp $R2 $R3 get
Goto loop

get:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 " " get
StrCpy $R0 $CMDLINE "" $R2

Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd

I changed to use my new way, though, because this older code will only work with one command-line parameter (and I was planning ahead since I know that I'll need to support more).

Instructor
24th April 2006, 19:27
I'm not sure why the FileFunc GetParameters would have a problem, though, since I thought it was based from the GetParameters that use to be in the help.I'll repeat:
What command line?
MessageBox MB_OK "[$CMDLINE]"
What returns ${GetParameters}?
${GetParameters} $R0
MessageBox MB_OK "[$R0]"
What returns sunjammer's "GetParameters"?
Call GetParameters
Pop $R0
MessageBox MB_OK "[$R0]"

goldy1064
24th April 2006, 21:32
$CMDLINE on both is

"C:\Documents and Settings\HP_Owner\×ÀÃæ\Setup_getparameters.exe"

However, depending on which localized OS I run it on, I get a different result for what GetParameters returns. Using the original GetParameters function, the return value is "". However, with the new GetParameters function, the return value on a Chinese OS is " " (a space). I did a filewrite for all of this to be sure I wasn't missing any characters.

Instructor
25th April 2006, 05:39
Can you write hex code of the $CMDLINE?
FileOpen $0 HexCmd.txt w
FileWrite $0 $CMDLINE
FileClose $0And open with hex viewer/editor. Something like:433A5C446F63756D656E747320616E642053657474696E67735C48505F4F776E65725CD7C0C3E65C53657475705F676574706172616D65746572732E657865

Edit:
Or better attach this file

goldy1064
25th April 2006, 16:27
Attached are the files.

Setup_filefunc_getparameters.log - GetParameters using FileFunc header.

Setup_getparameters.log - GetParameters using sunjammer's GetParameters.

Setup_getparameters_cmdline.log - echo of $CMDLINE.

Instructor
25th April 2006, 17:17
Hm... can't reproduce. If you run program as:
"C:\Documents and Settings\HP_Owner\×ÀÃæ\Setup_getparameters.exe" -cdWhat return each of the functions?

goldy1064
25th April 2006, 20:23
If I try to run this from the desktop, I get a Windows alert saying that I need to Add/Remove programs through the Control Panel. This bad behaviour only happens on these systems when the full path has a localized string within it (like the Desktop).

mtconleyuk
13th November 2008, 09:29
I've just run into this exact same problem myself, on a Japanese system. I do the following:

${GetParameters} $0

${GetOptions} "$0" "-A" $1
${Unless} ${Errors}
IntOp $doAllUsersInstall 1 +
${EndUnless}

GetParameters() returns a string containing Japanese characters; GetOptions() then fails to parse the string correctly, and reports that the option exists (i.e., no error condition is set), even though it isn't.

As noted earlier, this occurs whenever the installer is launched from a location whose path contains non-Roman characters, so that the path to the executable, specified on the command line, screws up the parsing.

It's been 3 years since the last posting on this topic. Has there been a resolution? Is there a workaround, or a

mtconleyuk
13th November 2008, 09:31
Hm. Forgot to finish that last sentence, but you get the point. And, okay, it's actually been 2 years, but still....

designer_nexus
23rd March 2010, 16:27
Anyone resolve this? unicode NSIS doesn't seem to do it.

designer_nexus
25th March 2010, 16:45
My bad. This is resolved by the unicode installer.