Powershell 使用路径空间启动进程

Powershell 使用路径空间启动进程,powershell,Powershell,我的路径间距有问题。这项工作: $mediaPath = 'C:\Scripts' $installerPath = Join-Path $mediaPath -ChildPath 'test.msi' Start-Process -FilePath msiexec.exe -ArgumentList "/i $installerPath /quiet" -Wait -NoNewWindow 这并不是: $mediaPath = 'C:\Scripts\Directory with a sp

我的路径间距有问题。这项工作:

$mediaPath = 'C:\Scripts'
$installerPath = Join-Path $mediaPath -ChildPath 'test.msi'

Start-Process -FilePath msiexec.exe -ArgumentList "/i $installerPath /quiet" -Wait -NoNewWindow
这并不是:

$mediaPath = 'C:\Scripts\Directory with a space\foo'

启动进程
传递参数时如何处理路径中的空格?

传递参数不正确

$media = 'C:\Scripts\test.msi'

Start-Process -FilePath msiexec -ArgumentList @('/i',"`"$media`"",'/quiet') -Wait -NoNewWindow

谢谢。你能解释一下倒勾和引号的要求吗<代码>“
我是PowerShell新手。@LightningWar这些是转义字符,因此它将参数作为带引号的字符串传递,允许参数中有空格。如果您尝试将所有参数作为一个字符串传递,它会将整个字符串解释为一个参数,这取决于您调用的程序来解释它,因此在本例中我传递的字符串数组。注意:转义字符不以字符串文字(
'
)进行解释。