Archive: nsexec parameters with quotes


nsexec parameters with quotes
I'm trying to write a script that will retrive the system manufacturer of the system and then install one program or another depending on the result. I have the cmd line command but am having trouble converting it so that I can use it in an nsis script.

The cmd line command is:


"systeminfo" |find "System Manufacturer:"


I tried converting this into a nsExec::ExecToStack command


nsExec::ExecToStack '"systeminfo" |find "System Manufacturer:" '
Pop $0
Pop $1
MessageBox MB_OK '$0'
MessageBox MB_OK '$1'


However no matter which combinations of ",',` I use I can't seem to get a command that works. Also tried using $\" but the double quote is then completly ignored.

Thanks in advance for help!

Re: nsexec parameters with quotes

Originally posted by pbingel
I'm trying to write a script that will retrive the system manufacturer of the system and then install one program or another depending on the result. I have the cmd line command but am having trouble converting it so that I can use it in an nsis script.

The cmd line command is:

"systeminfo" |find "System Manufacturer:"


I tried converting this into a nsExec::ExecToStack command


nsExec::ExecToStack '"systeminfo" |find "System Manufacturer:" '
Pop $0
Pop $1
MessageBox MB_OK '$0'
MessageBox MB_OK '$1'


However no matter which combinations of ",',` I use I can't seem to get a command that works. Also tried using $\" but the double quote is then completly ignored.

Thanks in advance for help!
I think nsExec can only run executables, it can NOT execute shell commands, like the COMMAND shell can do. So the "|" won't work. You'll have to do it like this:

Section
nsExec::ExecToStack '"$SYSDIR\cmd.exe" /c systeminfo | find "System Manufacturer:"'
Pop $0
Pop $1
MessageBox MB_OK '$0'
MessageBox MB_OK '$1'
SectionEnd

Thanks for the reply.

Launching systeminfo isn't the problem. nsExec uses the command line so there is not issue with calling command line executables like systeminfo. However the problem lies in how nsexec gives the command line parameters. Parameters in nsexec are seperated by a space but many parameters for command line arguments have spaces in them. No matter how I mix quotes I always get

ERROR:Invalid Argument/Option- '|find'.
or
ERROR:Invalid Argument/Option- '|find System' <notice quote was ignored

The argument must be exactly '|find "System Manufacturer:" including the quotes around System Manufacturer:

Any help would be appreciated.


I already posted a working (tested) example ...

http://img153.imageshack.us/img153/4...nsisdk3.th.png


I apologize when I copied your example earlier and tried it and it gave me an error and actually crashed the editor twice. But when I tried it again now it worked fine...

Thanks very much and again I apologize.


No problem. You may even do it this way, using only *full* paths:

OutFile "TestCMD.exe"
Name "Sysinfo Test"

!define CmdLine '"$SYSDIR\cmd.exe" /c ""$SYSDIR\systeminfo.exe" | "$SYSDIR\find.exe" "System Manufacturer:""'

Section
DetailPrint 'Exec: ${CmdLine}'
nsExec::ExecToStack '${CmdLine}'
Pop $0
Pop $1
DetailPrint "Exit Code: $0"
DetailPrint "$1"
MessageBox MB_OK '$1'
SectionEnd


(Yes, the quotes are correct, although it looks strange. The "cmd.exe" has some ugly quotes handling ^^)