Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows “意外”;系统找不到指定的驱动器。”;批处理文件_Windows_Batch File - Fatal编程技术网

Windows “意外”;系统找不到指定的驱动器。”;批处理文件

Windows “意外”;系统找不到指定的驱动器。”;批处理文件,windows,batch-file,Windows,Batch File,批处理文件(Windows 7 x64)有问题。我已设法将其缩减为以下内容(有两个空注释行;是否有实际注释似乎无关紧要): 将其放入批处理文件中,然后在不带参数的情况下运行,将生成以下输出: A The system cannot find the drive specified. B 删除::行中的一行,或者删除周围的行(如果),可以修复问题,从而获得预期的输出: A B 这是怎么回事?为什么它要找一个驱动器 编辑 感谢您对far的回复。所以我的问题可以归结为: 确定:是指“注释开始”还是

批处理文件(Windows 7 x64)有问题。我已设法将其缩减为以下内容(有两个空注释行;是否有实际注释似乎无关紧要):

将其放入批处理文件中,然后在不带参数的情况下运行,将生成以下输出:

A
The system cannot find the drive specified.
B
删除
::
行中的一行,或者删除周围的
行(如果
),可以修复问题,从而获得预期的输出:

A
B
这是怎么回事?为什么它要找一个驱动器

编辑

感谢您对far的回复。所以我的问题可以归结为:

确定
是指“注释开始”还是“驱动器号冒号”的规则是什么


也许切换回
REM
添加注释更容易,这样就不会出现歧义,但我确实发现
样式更容易阅读。

是一个有效的驱动器。就像
c:
d:
一样,但字母是

因此,您的行正在尝试从当前驱动器更改为驱动器


示例:尝试
subst::c:\
,然后尝试
dir::\

这是批处理代码块中的obscoure效果

在代码块中,一行中的标签始终需要具有完全不同语法规则的辅助行(对于辅助行)。

辅助行必须是命令或简单标签,但不能是括号、双冒号或附加括号的内部命令

MC ND解释说这里使用的
就像普通的驱动器号一样,这是真的
但只有在第二行中,即使您可以通过
subst::C:\
来抑制错误,该行的处理方式就像标签一样(您不能启动任何东西)

并且第二行接受
&
,即使该行是一个标签

不合格样品

(
:Label at the end fails
)

(
:label
  ( 
    echo new Block fails
  )
echo ...
)

(
:label
:: Double colon fails
)

(
:label
echo( fails also, as now a file named "echo(" is searched for execution
)
现在有工作了

(
::Works
:with a "normal" label in the second line
)

(
:But this label! & echo This will not echo'd
:but & echo You can see this !
)

(
:label
echo or a simple command works too
)
有时将
::
用作辅助行,如果您不关心辅助行,这可能会导致块内部出现问题

编辑:回答第二个问题

确定::是否表示“开始评论”的规则是什么 还是“驱动器号冒号”


第一个
::
始终是一个注释或标签,下一行始终是
驱动器号冒号

+1,但
不是一个“完全满意”的驱动器,
没有参数的subst
不会显示此项。@endro、
mountvol::/L
mountvol c:/L
。对我来说,两者都是同一卷。但是是的,不是系统中的所有工具都能使用它。但是为什么在两行
之间插入一个
echo x
时它能工作呢?+1我已经测试了它,它确实抑制了第二行中的语法错误。错误在第二个
,以及您所述的原因中。第一行是一个标签,第二行应该是一个有效的命令,如果::可以被认为是有效的,则执行它。是的,您可以使用
start::\windows\system32\calc.exe
启动一些东西。如前所述,并非系统的所有部分都能处理它。
(
:Label at the end fails
)

(
:label
  ( 
    echo new Block fails
  )
echo ...
)

(
:label
:: Double colon fails
)

(
:label
echo( fails also, as now a file named "echo(" is searched for execution
)
(
::Works
:with a "normal" label in the second line
)

(
:But this label! & echo This will not echo'd
:but & echo You can see this !
)

(
:label
echo or a simple command works too
)