首页 > 解决方案 > 在 BATCH 文件中的引号内传递引号

问题描述

我一直在寻找解决这个问题的方法,但到目前为止我一直没有成功。我正在尝试使用批处理文件打开两个程序。问题是这些文件的两个路径都包含空格,并且这些路径之一已经用引号引起来。因为第二个文件(.gh 文件)没有打开。我已经尝试将第二条路径放在引号中,并使用\字符转义引号,但没有任何结果。任何帮助表示赞赏。

@ECHO OFF
cd C:\Users\\Google Drive\Rhino Werk\MT1458\WIP
"C:\Program Files\Rhino 6\System\Rhino.exe" /nosplash /runscript="-grasshopper editor load document open C:\Users\<username>\Google Drive\Rhino Werk\MT1458\WIP\MT1458_HullGenerator_V2.64_NAKIJKMODEL.gh _enter" "C:\Users\<username>\Google Drive\Rhino Werk\MT1458\WIP\MT1458_HullGenerator_V2.59_001.3dm"

标签: batch-filegrasshopperrhino3d

解决方案


@ECHO OFF
cd /d "C:\Users\\Google Drive\Rhino Werk\MT1458\WIP"
"C:\Program Files\Rhino 6\System\Rhino.exe" /nosplash /runscript="-grasshopper editor load document open \"%userprofile%\Google Drive\Rhino Werk\MT1458\WIP\MT1458_HullGenerator_V2.64_NAKIJKMODEL.gh\" _enter \"%userprofile%\Google Drive\Rhino Werk\MT1458\WIP\MT1458_HullGenerator_V2.59_001.3dm\""

这将遵循使用反斜杠转义内部双引号的 C++ argv 规则。这是否有效尚不清楚,因为我没有或使用 Rhino。


推荐阅读