Old 12th September 2008, 20:08   #1
pbingel
Junior Member
 
Join Date: Sep 2008
Posts: 14
Question 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:
code:

"systeminfo" |find "System Manufacturer:"



I tried converting this into a nsExec::ExecToStack command

code:

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!
pbingel is offline   Reply With Quote
Old 13th September 2008, 00:45   #2
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Re: nsexec parameters with quotes

Quote:
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:
code:

"systeminfo" |find "System Manufacturer:"



I tried converting this into a nsExec::ExecToStack command

code:

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:

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


My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 15th September 2008, 13:53   #3
pbingel
Junior Member
 
Join Date: Sep 2008
Posts: 14
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.
pbingel is offline   Reply With Quote
Old 15th September 2008, 14:18   #4
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
I already posted a working (tested) example ...


My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Old 15th September 2008, 14:27   #5
pbingel
Junior Member
 
Join Date: Sep 2008
Posts: 14
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.
pbingel is offline   Reply With Quote
Old 15th September 2008, 15:00   #6
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
No problem. You may even do it this way, using only *full* paths:

code:
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 ^^)

My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI
LoRd_MuldeR is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump