Windows批处理文件 - 系统找不到指定的批次标签 [英] Windows batch file - The system cannot find the batch label specified

查看:4457
本文介绍了Windows批处理文件 - 系统找不到指定的批次标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DOS批处理文件和标签有问题。
我不断收到此错误:

I'm having a problem with a DOS batch file and labels. I keep getting this error:

系统无法找到批次标签
  指定

The system cannot find the batch label specified


  • 两台电脑;在windowsXP和2003服务器。

  • 确定它是连接codeD为ASCII

  • Editted六角code为续行字符。试图反过来以CR,LF和CRLF更换所有。所有组合给我同样的错误。

  • 试过标签之前插入额外的字符,使标签过去512个字符。

下面是code:

cls
@echo off
SET zip=7za a dependencies.7z
call:dozip "c:\temp\dir.txt"

pause
goto exit

:dozip
  echo Testing 1.2.3...
  %zip% %1
goto:eof
:exit

下面是用CRLF(0D 0A)十六进制。

Here's the hex with CRLF (0d 0a).

63 6c 73 0d 0a 53 45 54 20 7a 69 70 3d 37 7a 61 20 61 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 37 7a 0d 0a 63 61 6c 6c 3a 64 6f 7a 69 70 20 22 63 3a 5c 74 65 6d 70 5c 64 69 72 2e 74 78 74 22 0d 0a 0d 0a 70 61 75 73 65 0d 0a 67 6f 74 6f 20 65 78 69 74 0d 0a 0d 0a 3a 64 6f 7a 69 70 0d 0a 20 20 65 63 68 6f 20 54 65 73 74 69 6e 67 20 31 2e 32 2e 33 2e 2e 2e 0d 0a 20 20 25 7a 69 70 25 20 25 31 0d 0a 67 6f 74 6f 3a 65 6f 66 0d 0a 3a 65 78 69 74

下面是控制台的输出(当我删除@echo关闭):

Here's the console's output (when I remove @echo off):

C:\>SET zip=7za a dependencies.7z

C:\>call:dozip "c:\temp\dir.txt"

C:\>echo Testing 1.2.3...
Testing 1.2.3...

C:\>7za a dependencies.7z "c:\temp\dir.txt"
The system cannot find the batch label specified - dozip

C:\>pause
Press any key to continue . . .

它从来没有真正创建7zip的文件,所以我想我可以假设它的崩溃在这条线;

It never actually creates the 7zip file, so I think I can assume that its crashing on this line;

7za a dependencies.7z "c:\temp\dir.txt"

如果我运行本身从命令提示符那行,它工作正常,并创建dependencies.7z,所以我不认为它必然与7za.exe有问题。

If I run that line by itself from a command prompt, it works fine and creates the dependencies.7z, so I don't think its necessarily a problem with 7za.exe.

我已经阅读此计算器的问题:
stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-ex

I've already read this stackoverflow question: stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-ex

和从该职位的联系;
help.wugnet.com/windows/system-find-batch-label-ftopict615555.html

and the link from that post; help.wugnet.com/windows/system-find-batch-label-ftopict615555.html

所以,我发现这个问题球员。

So, I found the problem guys.

我使用的技术我通常使用我只能真的形容为代理的批处理文件。我有一个文件夹名为C:\\脚本,我把几个批处理文件中有瞄准常用的前男友。这成为我所有的命令行工具绝对可以节省大量我的PATH变量。这样,我只需要添加C:\\脚本来我的道路,并创建一个代理的批处理文件,当我需要的东西。

I was using a technique I commonly use that I could only really describe as "proxy" batch files. I have a folder called c:\scripts, and I put several bat files in there to target commonly used exes. This saves my PATH variable from becoming absolutely massive with all of my command line tools. This way I only need to add c:\scripts to my PATH, and create a proxy batch file when I need something.

我7za.bat在C:\\ Scripts中,只包含这一点;

I had 7za.bat in c:\scripts, containing only this;

@echo off
"C:\Program Files\7-zip\7za.exe" %*

我改变了我的脚本这一点;

I changed my script to this;

SET zip="c:\program files\7-zip\7za.exe" a dependencies.7z

代替本;

SET zip=7za a dependencies.7z

和它完美地工作。

从避免在批处理文件中调用其他批处理文件。如果你这样做,你将需要preFIX它们与拨打

Avoid calling other batch files from within a batch file. If you do, you will need to prefix them with "call".

推荐答案

我要指出的是,测试1.2.3 ...和preSS任意键继续。线表示执行已成功去了:dozip标签,然后成功地返回给调用者

I would point out that the "Testing 1.2.3..." and "Press any key to continue . . ." lines indicate that execution has successfully gone to the :dozip label and then successfully returned to the caller.

是7za可执行实际上是一个批处理文件?如果我修改我的测试脚本有助手是一个批处理文件,我得到了同样的错误。解决方法是做呼叫%拉链%%1

Is the "7za" executable actually a batch file? If I modify my test script to have the helper be a batch file, I get the same error. The fix is to do 'call %zip% %1'

这篇关于Windows批处理文件 - 系统找不到指定的批次标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆