Start-Process ArgumentList 的 PowerShell 引号 [英] PowerShell quotes for Start-Process ArgumentList

查看:52
本文介绍了Start-Process ArgumentList 的 PowerShell 引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打开应用 tablacus explorer一个文件夹路径.这适用于以下格式:

I'm trying to have the app tablacus explorer open a folder path. This works fine with the following formatting:

$ex = 'S:\Tools\explorer\TE64.exe'
Start-Process $ex -ArgumentList '"Tabs,Close other tabs" "Open,C:\Program Files"'

但我真的很想将路径放在一个变量中 ($dir = 'C:\Program Files'),但我似乎无法正确使用引号,因此它会被解释正确.

But I would really like to have the path in a variable ($dir = 'C:\Program Files'), and I can't seem to get the quotes right so it gets interpreted properly.

感谢您的帮助.

推荐答案

我在 MS 博客:

$Args = @"
"Tabs,Close other tabs" "Open,$dir"
"@

start $ex -ArgumentList $Args

start $ex -ArgumentList """Tabs,Close other tabs"" ""Open,$dir"""

这篇关于Start-Process ArgumentList 的 PowerShell 引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆