Windows 7批处理错误“意外完成”
我正在使用Windows 7记事本编写一个简单的批处理文件,并收到一条无法识别或隔离的错误消息:Windows 7批处理错误“意外完成”,windows,batch-file,Windows,Batch File,我正在使用Windows 7记事本编写一个简单的批处理文件,并收到一条无法识别或隔离的错误消息: REM Robocopy script for Sequoia data collection REM Run WRITE three times, collect the results cd c:\Robo_results\Sequoia_tests for /L %%n in (1, 1, 1) do ( REM WRITE echo Testing again %%n )
REM Robocopy script for Sequoia data collection
REM Run WRITE three times, collect the results
cd c:\Robo_results\Sequoia_tests
for /L %%n in (1, 1, 1) do (
REM WRITE
echo Testing again %%n
)
for /L %%n in (1, 1, 1) do (
echo Pause for 60 seconds until the crawler (hopefully) finishes
)
输出:
c:\Robo_results\Sequoia_tests>run_Seq_robocopy2.bat
c:\Robo_results\Sequoia_tests>REM Robocopy script for Sequoia data collection
c:\Robo_results\Sequoia_tests>REM Run WRITE three times, collect the results
c:\Robo_results\Sequoia_tests>cd c:\Robo_results\Sequoia_tests
c:\Robo_results\Sequoia_tests>for /L %n in (1 1 1) do (
REM WRITE
echo Testing again %n
)
c:\Robo_results\Sequoia_tests>(
REM WRITE
echo Testing again 1
)
Testing again 1
finishes was unexpected at this time.
c:\Robo_results\Sequoia_tests> echo Pause for 60 seconds until the crawler (hopefully) finishes
c:\Robo_results\Sequoia_tests>
我不明白他指的是什么。
我使用了一个十六进制编辑器,看到0d0a用于crlf,看起来还可以
有趣的是:我从记事本上复制并粘贴在本次提交中的文本有CR和LF,但显示的问题没有。重新表述该语句:在批处理文件REM和echo中,启动新行,但在此显示中,它们没有。
非常感谢。
NealFinishs是批处理文件中拼写准确的单词,如下所示:
for /L %%n in (1, 1, 1) do ( echo Pause for 60 seconds until the crawler (hopefully) finishes )
这有几个部分:
环路
由括号分隔的子shell
子shell中的命令
echo Pause for 60 seconds until the crawler (hopefully
右括号后面有一些垃圾:
finishes )
最后一部分会导致错误
您的意思是让第一个右括号成为消息的一部分,而不是结束子shell,但命令解释器不知道这一点。尝试在不使用对shell有特殊意义的字符的情况下编写消息。或者使用一些引号。他也可以用^字符对括号进行转义。
finishes )