首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows Powershell文件夹名称中的Parentheses

Windows Powershell文件夹名称中的Parentheses
EN

Stack Overflow用户
提问于 2020-08-02 04:44:25
回答 2查看 394关注 0票数 1

这里是Powershell n00b。我想使用PowerShell挂载一个iso。我成功地做到了这样:

代码语言:javascript
复制
PS C:\> PowerShell Mount-DiskImage C:\3D_Ultra_Pinball_Thrillride\pinball-disc.iso


Attached          : True
BlockSize         : 0
DevicePath        : \\.\CDROM2
FileSize          : 214403072
ImagePath         : C:\3D_Ultra_Pinball_Thrillride\pinball-disc.iso
LogicalSectorSize : 2048
Number            : 2
Size              : 214403072
StorageType       : 1
PSComputerName    :

但是现在我想做一个在文件名中有括号的操作,如下所示:

代码语言:javascript
复制
PS C:\> PowerShell Mount-DiskImage "C:\Program Files (x86)\Warcraft III\warcraft-disc.iso"
x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:35
+ Mount-DiskImage C:\Program Files (x86)\Warcraft III\warcraft-disc.iso
+                                   ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

如何避免括号?Backticks似乎不工作,也不引用单引号或双引号的路径。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-08-02 05:06:50

单引号使它成为字符串文字,应该可以正常工作。为什么在powershell提示符中调用powershell?也许这就是问题所在。

代码语言:javascript
复制
PS C:\> Mount-DiskImage 'C:\Program Files (x86)\Common Files\SLI_3.0.0_A00 (1).iso'


Attached          : True
BlockSize         : 0
DevicePath        : \\.\CDROM1
FileSize          : 1882193920
ImagePath         : C:\Program Files (x86)\Common Files\SLI_3.0.0_A00 (1).iso
LogicalSectorSize : 2048
Number            : 1
Size              : 1882193920
StorageType       : 1
PSComputerName    :
票数 1
EN

Stack Overflow用户

发布于 2020-08-02 08:11:45

转义括号:

代码语言:javascript
复制
Mount-DiskImage "C:\Program Files `(x86`)\Common Files\SLI_3.0.0_A00 `(1`).iso"

回拨(`)是PowerShell中的转义字符。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63212469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档