Skip to content
⌘ NSIS Forum Archive

parameter question

9 posts

Yathosho#

parameter question

my script uses the GetParameters and the GetFileName function from the archive. the idea is to let my installer open a file, which works..

this works
MyInstaller.exe C:\Documents and Settings\MyFile.ini

this does not work
MyInstaller.exe "C:\Documents and Settings\MyFile.ini"

i tried using '-quotes in my installer, but it still doesn't work. any hint how to avoid this?
Afrow UK#
You need to remove the quotes. GetParamaters leaves them on.
Use StrReplace on the archive:


-Stu
Yathosho#
another weird thing is happening
IfFileExists "$Input" ValidInput 0
IfFileExists "$EXEDIR\$Input" 0 InvalidInput
StrCpy $Input "$EXEDIR\$Input"
Goto ValidInput
the first file-check works (full path to file is supplied). however, i added a second check, in case the file is stored in the same dir as my installer. that part never works.
Instructor#edited
Name 'Output'
OutFile 'Output.exe'

!include "FileFunc.nsh"
!insertmacro GetParameters

!include "WordFunc.nsh"
!insertmacro WordFind2X


Section
${GetParameters} $R0

StrCpy $0 0

loop:
IntOp $0 $0 + 1
${WordFind2X} '$R0' '"' '"' 'E+$0' $1
IfErrors end

MessageBoX MB_YESNO "[$1]$\n$\nNext Parameter?" IDYES loop

end:
SectionEnd
Command line example:
Output.exe "C:\Documents and Settings\File1.ini" "C:\Documents and Settings\File2.ini" ...
Script used headers
Instructor#
You wrote:
was hoping on something simpler/shorter...
My previous post it's answer to your first question.

Second question:
If full path to "$Input" is supplied then "$EXEDIR\$Input" - incorrect path.
Yathosho#
yes, but if i don't supply a full path, then IfFileExists still returns that the file exists. later when i'm using ReadRegStr it doesn't work, because it'd need the full path.

my script never comes to the 2nd IfFileExist, unregarding if i supply a path or not. shouldn't this be considered as a bug in nsis?
Instructor#
IfFileExists "$EXEDIR\$Input" 0 +3
StrCpy $Input "$EXEDIR\$Input"
Goto ValidInput
IfFileExists "$Input" ValidInput InvalidInput