2014-02-13 90 views
0

- 基本信息 我有這個SourceForge項目稱爲E-Series這使得某些編碼任務更容易,在這個問題上,我會專門談論E系列的「簡易命令行」。從調用CMD原創作品的批處理文件,但.bat文件不

-NOTES

- 一旦再次,在標題爲好,從調用CMD原批處理文件(通過將運行Access它> CMD)不工作,但是從.bat文件調用它旨在稱它不是。

- 我打電話的批處理文件有參數。

- 什麼我有

HERE都全程運行程序(下載,如果你想更具體的信息)所需的文件;請注意,當嘗試鍵入我的自定義命令(您可以通過鍵入幫助來查看)(例如「newfolder(name)」或「newfile(name和extension)」)失敗,但是從cmd調用它。如果你下載了它,只需打開cmd的command.bat即可。

- 什麼我需要

我需要一個.bat文件,可以「正常」調用帶有參數的批處理文件。

-where會有外遇 -CALLING批處理文件從.bat文件

我認真建議您download my program纔去這裏,否則它可能會沒有任何意義給你。

我曾經發現錯誤發生在哪裏;

@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上)示出了whenenver I型在 「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) 

詳細屏幕 HERE 這是沒有意義的。這與14 was unexpected at this time.是什麼意思? 使用我的命令解析的方法是首先,它檢查輸入是否對應於某些批處理文件命令,如「clear,cls,list,when,help」,但最後還有一個「call」函數,因爲外部計劃旨在處理目錄(及以上)的動作,如創建一個新的文件夾,新建文件等從CMD

-Calling批處理文件

正如我已經說過,從調用批處理文件CMD是FLAWLESS; enter image description here

我該如何解決這個問題?變得非常沮喪:(告訴我,如果你需要更多的信息

回答

2

在空間可以包括或&字符,那麼你需要雙引號地方:

不是這個:

if %ecl_command% == help goto help 

但這一點,並在所有類似的路線:

if /i "%ecl_command%" == "help" goto help 

的/我做的比較不區分大小寫

+0

似乎仍然失敗; [這裏是關於代碼和輸出的截圖](http://i.imgur.com/2rPomot.png) – EpicTonic

+0

新發現:在諸如call newfolder 14之類的命令之前添加'call'工作...這是否意味着它忽略代碼中已經創建的'call'命令? – EpicTonic

+0

它似乎也將命令傳遞給'cmd',因此如果它檢測到未知命令,則會傳遞正常的'cmd'錯誤。爲什麼是這樣? – EpicTonic

1

檢查你的.bat文件的編碼。當我用UTF-8,命令提示顯示的錯誤:

C:\Users\***\Desktop>´╗┐cmd 
'´╗┐cmd' is not recognized as an internal or external command, 
operable program or batch file. 

當我用ANSI編碼時,bat文件發揮預期。

相關問題