- NSIS Discussion
- parameter question
Archive: parameter question
Yathosho
14th February 2005 17:36 UTC
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
14th February 2005 18:59 UTC
You need to remove the quotes. GetParamaters leaves them on.
Use StrReplace on the archive:
http://nsis.sourceforge.net/archive/...ances=0,11,122
-Stu
Yathosho
14th February 2005 19:47 UTC
was hoping on something simpler/shorter, but that'll do. thanks, stu :)
Yathosho
14th February 2005 21:35 UTC
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
15th February 2005 09:00 UTC
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
Yathosho
15th February 2005 13:11 UTC
but what exactly is it, that doesn't make the code of my previous post work?
Instructor
15th February 2005 14:07 UTC
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
15th February 2005 14:57 UTC
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
15th February 2005 16:31 UTC
IfFileExists "$EXEDIR\$Input" 0 +3
StrCpy $Input "$EXEDIR\$Input"
Goto ValidInput
IfFileExists "$Input" ValidInput InvalidInput