Page 1 of 1 1
Topic Options
#181859 - 2007-10-23 03:44 PM Shelling out with nested quotes
iso Offline
Fresh Scripter

Registered: 2007-06-29
Posts: 10
I am trying to shell out and run the following command.

 Code:
c:\windows\microsoft.net\framework\v2.0.50727\caspol -machine -addgroup LocalIntranet_Zone -strong -hex 002BFA80333BF HostedWinFormsControls -noversion ALPHAWeb -description "Permissions for WinForms Controls hosted in the Aplha Web Application" -name Intranet_PDSHostedWinFormsControls  


My kixtart
 Code:
Shell "CMD /C %SYSTEMROOT%\microsoft.net\framework\v2.0.50727\caspol -machine -addgroup LocalIntranet_Zone -strong -hex 002BFA80333BF  HostedWinFormsControls -noversion ALPHAWeb -description "Permissions for WinForms Controls hosted in the Alpha Web Application" -name Intranet_PDSHostedWinFormsControls"


I'm running into problems with the description parameter which has quotes around it. I've tried single quotes, double quotes, and no quotes. What is the proper quoting or escape?

Thanks in advance!


Edited by iso (2007-10-23 04:14 PM)

Top
#181860 - 2007-10-23 04:11 PM Re: Shelling out with nested quotes [Re: iso]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Use single quotes in your Shell command:
eg: Shell '%COMSPEC% /c yourcommand -arg "this and that"'

Use %COMSPEC%, not CMD

Build a command string instead of placing everything in the Shell statement
$Cmd = 'blah-blah'
$Cmd = $Cmd + 'More stuff'
$Cmd = $Cmd + 'even more "stuff here"'
; Next 2 lines for debugging
'Running:' ?
$Cmd ?
Shell $Cmd

We really don't need to see the entire HEX string - please trim your original post to prevent the long lines.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#181861 - 2007-10-23 04:30 PM Re: Shelling out with nested quotes [Re: Glenn Barnas]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Personally I like to break long complex commands up like the following, with the parameters on a seperate line. It makes it easy to comment them out, remove them or add new parameters. I also find it easier to read.

 Code:
Shell '"'+%COMSPEC%+'" /C'
	+' "'+%SYSTEMROOT%+'\microsoft.net\framework\v2.0.50727\caspol"'
	+' -machine'
	+' -addgroup LocalIntranet_Zone'
	+' -strong'
	+' -hex 002BFA80333BF  HostedWinFormsControls'
	+' -noversion ALPHAWeb'
	+' -description "Permissions for WinForms Controls hosted in the Alpha Web Application"'
	+' -name Intranet_PDSHostedWinFormsControls"

Top
#181908 - 2007-10-24 07:56 PM Re: Shelling out with nested quotes [Re: Richard H.]
iso Offline
Fresh Scripter

Registered: 2007-06-29
Posts: 10
Richard, should the last line be closed with a "' or just "?
Top
#181909 - 2007-10-24 08:48 PM Re: Shelling out with nested quotes [Re: iso]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Actually, the " should be a '

the beginning and end quotes of that line don't match.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#181927 - 2007-10-25 12:26 PM Re: Shelling out with nested quotes [Re: Glenn Barnas]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Glenn Barnas
Actually, the " should be a '

the beginning and end quotes of that line don't match.


Quite correct. See how easy it is to spot the deliberate (ahem!) error when you format the command in this way.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.063 seconds in which 0.033 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org