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

如何在Runbox中使用iwr下载文件到含空格的目录?

解决PowerShell在Runbox中含空格路径的执行错误

问题原因

你的代码在PowerShell控制台可正常运行,但Runbox执行时出错,核心原因是Runbox将代码拼接为单行后,丢失了路径字符串的双引号,导致含空格的路径被拆分为多个无效语法片段,触发Unexpected token错误。

可行解决办法

方法1:用转义双引号包裹路径

在Runbox中,给路径字符串的双引号添加PowerShell转义符(反引号`),确保Runbox不会移除引号:

$f = `"$env:userprofile/desktop/art folder/art.png`"
iwr DropBoxUrl -o $f

方法2:用Join-Path构建路径(推荐)

使用PowerShell内置的Join-Path命令拼接路径,自动处理空格和系统路径分隔符,避免手动写路径的语法问题:

$f = Join-Path -Path $env:userprofile -ChildPath "desktop\art folder\art.png"
iwr DropBoxUrl -o $f

也可分步骤拼接,逻辑更清晰:

$desktopPath = Join-Path -Path $env:userprofile -ChildPath "desktop"
$f = Join-Path -Path $desktopPath -ChildPath "art folder\art.png"
iwr DropBoxUrl -o $f

方法3:用字符串拼接替代直接路径

手动拼接路径字符串,绕开引号解析问题:

$f = $env:userprofile + "/desktop/art folder/art.png"
iwr DropBoxUrl -o $f

内容的提问来源于stack exchange,提问作者I am Jakoby

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 20:25:17