Archive: GetOptions question


GetOptions question
Hi, I noticed that GetOptions macro is giving me different results depending on the presence os spaces on path name. For example, c:\path gives me 'result' and c:\pa th gives me '"result"' (with "s). I got errors depending on which path I use command line params with NSIS.


Well, $CMDLINE is the culprit. The second part of params does not have quotations marks if path name does not have spaces. Is this a bug?


Name "Output"
OutFile "Output.exe"

!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetOptions

Section
${GetParameters} $0
${GetOptions} '$0' '/LOG=' $1

MessageBox MB_OK '$$0={$0}$\n$$1={$1}'
SectionEnd

Pardon me, Instructor! I meant GetParameters and not GetOptions macro, sorry!

As I said in my last post, the problem is with $CMDLINE and not with the macros.


Test this sript in 2 different directories, one like 'c:\test' and another like 'c:\test 2'. You will see that one result has quotations marks and the other does not have.


What the contents of the $CMDLINE?


Let me explain in another way. The contents of $CMDLINE (and of GetParameters macro too) will differ depending on the folder name. If there are spaces in path name where the installer is (like c:\test 2\installer.exe), when I drag and drop a file (for example test.txt) in the same path over installer.exe $CMDLINE will be '"C:\test 2\commandline.exe" "C:\test 2\test.txt"' and GetParameters macro '"C:\test 2\test.txt"'. If I change the folder's name to c:\test and drag and drop test.txt again over installer.exe the $CMDLINE will be '"C:\test\commandline.exe" C:\test\test.txt' and GetParameters macro 'C:\test\test.txt' (without quotations marks).


'"C:\test 2\commandline.exe" "C:\test 2\test.txt"' -> '"C:\test 2\test.txt"'
'"C:\test\commandline.exe" C:\test\test.txt' -> 'C:\test\test.txt'
It is correct GetParameters simply cut first part that contain exe name.


I know that. I have put an if statement to overcome these extra quotations marks depending on spaces in the path. I just wonder why $CMDLINE is giving me theses different results.


The system (OS) adds the quotes; $CMDLINE is just showing you what it gets.

I did a couple little tests to try to prove this, first by using Notepad (drag a file onto it, and then check its CMDLINE by using Process explorer), and also by dragging files into a cmd window. Both experiments show quotes being added when the pathnames include spaces.

Don


Thanks for the info, demiller9. I have fixed my script to deal with this strange OS behavior.