PowerShell 引用 Start-Process ArgumentList

Dar*_*te1 9 quotes powershell

我正在尝试让应用程序tablacus explorer打开文件夹路径。这适用于以下格式:

$exe = 'S:\Tools\explorer\TE64.exe'
Start-Process $exe -ArgumentList '"Tabs,Close other tabs" "Open,C:\Program Files"'
Run Code Online (Sandbox Code Playgroud)

但我真的很想在变量 ( $dir = 'C:\Program Files') 中包含路径,但我似乎无法正确获取引号,因此无法正确解释它。

Dar*_*te1 9

我在MS 博客上找到了两个解决方案:

$Args = @"
"Tabs,Close other tabs" "Open,$dir"
"@
    
Start-Process $exe -ArgumentList $Args
Run Code Online (Sandbox Code Playgroud)

或者

Start-Process $exe -ArgumentList """Tabs,Close other tabs"" ""Open,$dir"""
Run Code Online (Sandbox Code Playgroud)