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

如何在PowerShell中添加引号以解决Scoop安装报错问题

修复Cygwin环境下安装Scoop的PowerShell命令引号问题

问题背景

需要在Cygwin shell中执行命令完成以下操作:

  • 请求管理员权限
  • 启动PowerShell窗口
  • 执行Scoop的管理员安装命令

原命令存在引号嵌套错误,导致&符号未被正确包裹,无法正常执行脚本。原命令解析后为:

iex & {<scoop installation script>} -RunAsAdmin

期望的正确解析格式应为:

iex "& {$(irm get.scoop.sh)} -RunAsAdmin"

修正后的命令

powershell -NoProfile -ExecutionPolicy Bypass -Command 'Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -NoExit -Command iex \`"& {$(irm get.scoop.sh)} -RunAsAdmin\`"" -Verb RunAs -Wait'

修正说明

在Cygwin的bash环境中,需要通过\转义PowerShell所需的双引号,同时保持外层单引号的包裹,确保参数传递时的正确性:

  • 外层用单引号'包裹PowerShell的-Command参数,避免bash解析内部的特殊字符
  • 对需要传递给内层PowerShell的双引号,使用\转义,最终让内层PowerShell接收到被双引号包裹的& {$(irm get.scoop.sh)} -RunAsAdmin参数,满足Scoop安装的语法要求

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 19:02:36