tags:

views:

52

answers:

3

I want to call a perl script from powershell where a parameter is quoted:

myProg -root="my path with spaces"

I've tried to use -root='"my path with spaces"', -root='my path with spaces', -root=\"my path with spaces\", but nothing seems to work. After pressing <ENTER>, I see >> as a prompt.

How do I pass this quoted argument on the command line in Powershell?

+1  A: 

Try putting the entire argument in quotes and escape the inner quotes, that way powershell won't try to parse it:

myProg '-root=\"my path with spaces\"'
zdan
A: 

I solved a similar issue with

Invoke-Expression '&.\myProg.exe `-u:IMP `-p: `-s:"my path with spaces"'

Hope this helps.

Filburt
A: 

It may be useful to explicitly denote each command-line argument. Instead of relying on the parser to figure out what the arguments are via whitespace, you explicitly create an array of strings, one item for each command-line argument.

$cmdArgs = @( `
    '-root="my path with spaces"', `
    'etc', `
    'etc')

& "C:\etc\myprog.exe" $cmdArgs
Peter Seale