Try this
$re = "C:\Program Files (x86)\Y\RM 2010\RM.exe" $arg1 = '/W:\"cross\"' $arg2 = '/P:\"C:\Users\P\Documents\RM\RM.rep\"' $arg3 = '/U' $arg4 = '/S' & $re $arg1 $arg2 $arg3 $arg4
To get the "
marks included in arg1 & arg2, they had to be escaped \"
.
Don't know if the leading spaces on the parameters might of confused RM.EXE, but they should not be required.
Also, I split the /U /S
as these look like separate parameters.
After running the above through ECHOARGS.EXE, the output is as follows:
Arg 0 is </W:"cross">
Arg 1 is </P:"C:\Users\P\Documents\RM\RM.rep">
Arg 2 is </U>
Arg 3 is </S>
Command line:
"H:\temp\EchoArgs.exe" /W:\"cross\" /P:\"C:\Users\P\Documents\RM\RM.rep\" /U /S
Finally, if you are running PowerShell 3 (as per the tag), you should be able to make use of --%
. This will force PowerShell send the remainder of the command line 'as-is'. e.g.
& $re --% /W:"cross" /P:"C:\Users\P\Documents\RM\RM.rep" /U /S
Can still do is in PS 1 or 2 by using the following form:
& $re /W:\`"cross\`" /P:\`"C:\Users\P\Documents\RM\RM.rep\`" /U /S