簡體   English   中英

從原始cmd調用批處理文件有效,但是從.bat文件調用無效

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM