Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to suppress quotes in Powershell commands to executables
    primarykey
    data
    text
    <p>Is there any way to supress the enclosing quotation marks around each command-line argument that powershell likes to generate and then pass to external executables for command line arguments that have spaces in them?</p> <p>Here's the situation:</p> <p>One way to unpack many installers is a command of the form:</p> <p><code>msiexec /a &lt;packagename&gt; /qn TARGETDIR="&lt;path to folder with spaces&gt;"</code></p> <p>Trying to execute this from powershell has proven quite difficult. Powershell likes to enclose parameters with spaces in double-quotes. The following lines:</p> <p><code>msiexec /a somepackage.msi /qn 'TARGETDIR="c:\some path"'</code></p> <p><code>msiexec /a somepackage.msi /qn $('TARGETDIR="c:\some path"')</code></p> <p><code>$td = '"c:\some path"'</code></p> <p><code>msiexec /a somepackage.msi /qn TARGETDIR=$td</code></p> <p>All result in the following command line (as reported by the Win32 GetCommandLine() api):</p> <p><code>"msiexec" /a somepackage.msi /qn "TARGETDIR="c:\some path""</code></p> <p>This command line:</p> <p><code>msiexec /a somepackage.msi TARGETDIR="c:\some path" /qn</code></p> <p>results in</p> <p><code>"msiexec" /a fooinstaller.msi "TARGETDIR=c:\some path" /qn</code></p> <p>It seems that Powershell likes to enclose the results of expressions meant to represent one argument in quotation marks when passing them to external executables. This works fine for most executables. However, MsiExec is very specific about the quoting rules it wants and won't accept any of the command lines Powershell generates for paths have have spaces in them. </p> <p>Is there any way to suppress this behavior?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload