[英]Calling batch file from original cmd works, but from .bat files doesn't
-基本信息我有一个名为E-Series
sourceforge项目,它使某些编码任务更加容易,在这个问题上,我将专门讨论E-Series的“简易命令行”。
-笔记
-再一次,在标题中,也可以从原始cmd调用批处理文件(通过运行> cmd进行访问),但是从旨在调用该文件的.bat文件中调用该文件则不起作用。
-我正在调用的批处理文件具有参数。
-我有什么
这里是运行整个程序所需的所有文件(如果需要更多特定信息,请下载该文件); 请注意,尝试键入“ newfolder(名称)”或“ newfile(名称和扩展名)”之类的自定义命令(您可以通过键入帮助来查看)时失败,但可以从cmd调用它。 如果下载了cmd,只需打开command.bat。
-我需要的
我需要一个.bat文件,该文件可以“正确”调用带有参数的批处理文件。
-在哪里发生 -.bat文件中的批处理文件
我强烈建议您在这里下载我的程序 ,否则,它可能对您没有任何意义。
据推测,我发现了错误发生的地方。
@echo off
title Easy Command Line 0.1 E-Alpha
color a
:: The script is completely formatted in NotePad++ I recommend you use that when you're viewing the
:: Source code :)
:: This program is in extreme alpha say... 0.1 Alpha (Versions are counted every tenth (0.1),)
goto function_system_checkall
%clearcommand%
echo CONSOLE : Easy Command Line
echo CONSOLE : Type in "help" for a list of available commands. To enter batch mode
echo CONSOLE : type 'batchcommand'
:reset
set /p ecl_command="INPUT %cd%: "
if %ecl_command% == help goto help
if %ecl_command% == when echo %time%, %date%
if %ecl_command% == settings goto settings
if %ecl_command% == clear cls&goto reset
if %ecl_command% == clearscreen cls&goto reset
if %ecl_command% == cls cls&goto reset
if %ecl_command% == ping goto function_notyet
if %ecl_command% == checkall goto function_system_checkall
if %ecl_command% == navigate goto function_navigate
if %ecl_command% == debug @echo on
if %ecl_command% == disable_debug @echo off
call %ecl_command%
在调试模式下打开程序(@echo打开)显示,每次输入“ newfolder(名称)”或“ newfile(名称和扩展名)”时,都会导致输出:
INPUT D:\Projects\easycommandline: newfolder 14
14 was unexpected at this time.
D:\Projects\easycommandline>if newfolder 14 == help goto help
ECL crashed!
Press any key to relaunch ECL. It is recommended to go into debug mode (type debug)
详细的屏幕截图 这没有任何意义。 这是什么意思
14 was unexpected at this time.
? 首先使用我的命令解析的方法,它检查输入是否与某些批处理文件命令相对应,例如“ clear,cls,list,when,help”,但最后,由于外部程序存在“调用”功能用于处理目录(及更多)操作,例如创建新文件夹,新文件等。
-从cmd调用批处理文件
如我所说,从CMD调用批处理文件是FLAWLESS;
我怎样才能解决这个问题? 变得非常沮丧:(告诉我您是否需要更多信息
在可以包含空格或&
字符的地方,则需要双引号:
不是这个:
if %ecl_command% == help goto help
但是,在所有类似的行中:
if /i "%ecl_command%" == "help" goto help
/ i使比较大小写不敏感。
检查您的.bat文件的编码。 当我使用UTF-8时,命令提示符显示错误:
C:\Users\***\Desktop>´╗┐cmd
'´╗┐cmd' is not recognized as an internal or external command,
operable program or batch file.
当我使用ANSI编码时,.bat文件按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.