You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在CMD中不使用双引号启动PowerShell脚本(适配VBoxManage)

CMD环境下无双引号执行PowerShell命令的报错解决

问题场景

使用VBoxManage的post-install-command=参数时,该参数已占用双引号,无法在CMD环境下用双引号包裹PowerShell命令。执行以下命令时出现解析错误:

powershell.exe -noexit Start-BitsTransfer -Source 'download link' -Destination 'C:\test.txt'

报错信息

The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

原因分析

CMD环境中,单引号不被视为字符串边界符,命令传递给PowerShell时,单引号会被CMD部分解析丢失,导致PowerShell无法识别完整的字符串终止符。

解决方法

将命令中的单引号替换为两个连续的单引号,让PowerShell正确识别字符串边界。修改后的命令如下:

powershell.exe -noexit Start-BitsTransfer -Source ''download link'' -Destination ''C:\test.txt''

CMD会将连续的两个单引号传递给PowerShell,PowerShell会自动将其解析为一个单引号,从而正确识别源地址和目标路径的字符串。

内容的提问来源于stack exchange,提问作者Eretryg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 10:30:51