2013-02-14 70 views
0

我創建了一個。批處理將按照以下方式運行模型。在命令提示符(DOS)我這樣做: C:\ Program Files文件\門廊\門廊-1.0.2 \ EXEC> executePortico.bat name_model批處理文件 - 不被識別爲一個內部命令

例子:executePortico.bat ExampleCPPFederate

但這個錯誤:

「C:\文件」沒有被識別爲一個內部命令 或外置的,可運行的程序或批處理文件。 「C:\ Program Files文件\門廊\門廊-1.0.2 \例子\ CPP \ cpp13 \」 ExampleCPPFe derate.cpp 按任意鍵繼續。 。 。 ' 「C:\ Program Files文件\門廊\門廊-1.0.2 \例子\ CPP \ cpp13 \」 ExampleCPPF ederate2' 不被識別爲一個內部命令 或外置的,可運行的程序或批處理文件。 終止 - 普通

見我的代碼:

@echo off 

rem ########################### 
rem # implementation/version # 
rem ########################### 


rem ################################ 
rem # check command line arguments # 
rem ################################ 
:checkargs 
if "%0" == "" goto usage 
if "%1" == "" goto usage 


rem ####################### 
rem # test for JAVA_HOME # 
rem ####################### 
if "%JAVA_HOME%" == "" goto nojava 
goto rtihometest 

:nojava 
echo ERROR Your JAVA_HOME environment variable is not set! 
goto usage 

rem ####################### 
rem # test for RTI_HOME # 
rem ####################### 
:rtihometest 
call C:\Arquivos de programas\Portico\portico-1.0.2\etc\confvarsC.bat 
if not "%RTI_HOME%" == "" goto execute 


############################################ 
### (target) execute ####################### 
############################################ 
:execute 
SHIFT 
set PATH=%JAVA_HOME%\jre\bin\client;%RTI_HOME%\bin;%PATH% 
set RTI_FEDDIR="C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\" 
set EXEC="C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\" 


if "%0" == "m" goto exec1 

:exec1 
echo %EXEC%%1%.cpp 
pause 
%EXEC%%1%.cpp %2 
goto finish 


:usage 
echo usage: executePortico.bat [model] [nome modelo] 
goto err 

:err 
echo Terminated - Error 
goto end 

:finish 
echo Terminated - Normal 

:end 

我需要做到以下幾點: 我需要在這個軟件中,這樣的方式我創建了一個文件運行例子。蝙蝠其中,在命令提示符我這樣運行: executaPortic.bat name_model 我這樣做:

@echo off 

rem ########################### 
rem # implementation/version # 
rem ########################### 


rem ################################ 
rem # check command line arguments # 
rem ################################ 
:checkargs 


if "%0"=="" goto usage 
if "%1"=="" goto usage 



rem ####################### 
rem # test for JAVA_HOME # 
rem ####################### 
if "%JAVA_HOME%"=="" goto nojava 
goto rtihometest 

:nojava 
echo ERROR Your JAVA_HOME environment variable is not set! 
goto usage 

rem ####################### 
rem # test for RTI_HOME # 
rem ####################### 
:rtihometest 
call C:\Portico\portico-1.0.2\etc\confvarsC.bat 
if not "%RTI_HOME%"=="" goto execute 


############################################ 
### (target) execute ####################### 
############################################ 
:execute 
SHIFT 
set PATH=%JAVA_HOME%\jre\bin\client;%RTI_HOME%\bin;%PATH% 
set RTI_FEDDIR=C:\Portico\portico-1.0.2\examples\cpp\cpp13\ 
set EXEC=C:\Portico\portico-1.0.2\examples\cpp\cpp13\ 

rem ########################### 
rem # if "%0"=="m" goto exec1 
rem ########################### 

goto exec1 

:exec1 
echo %EXEC%%1.exe 
pause 
"%EXEC%%1.exe" %2 
goto finish 


:usage 
echo usage: executePortico.bat [model] [nome modelo] 
goto err 

:err 
echo Terminated - Error 
goto end 

:finish 
echo Terminated - Normal 

:end 

但是現在這個錯誤: C:\門廊\門廊-1.0.2 \ EXEC> executePortic.bat主 輸入行太長。

+0

在你的'if'語句中取''''周圍的空格。另外,從您的'set RTI_FEDDIR ='和'set EXEC ='值中刪除引號,並將'%EXEC %% 1%.cpp%2'更改爲''%EXEC %% 1%.cpp「%2'。 – rojo 2013-02-14 19:35:28

+0

在此之前改變安裝位置爲C:\門廊\門廊-1.0.2 我沒有你所說的話,請查看代碼的一部分: ':執行 SHIFT 設置PATH =%JAVA_HOME%\ JRE \ bin \ client;%RTI_HOME%\ bin;%PATH% set RTI_FEDDIR = C:\ Portico \ portico-1.0.2 \ examples \ cpp \ cpp13 set EXEC = C:\ Portico \ portico-1.0.2 \ examples \ CPP \ cpp13 \ 如果 「0%」 == 「M」 的goto exec1 :exec1 回聲%EXEC %% 1%的.cpp 暫停 「%EXEC %% 1%的.cpp」 %2 轉到完成 :使用 呼應用法:executePortico。蝙蝠[模型] [諾姆莫德洛] 轉到ERR :犯錯 回聲終止 - 錯誤 轉到結束 :完成 回聲終止 - 正常 :end'

David 2013-02-15 10:16:06

+0

但發生這樣的錯誤: C: \ Portico \ portico-1.0.2 \ exec> executePortico.bat main C:\ Portico \ portico-1.0.2 \ examples \ cpp \ cpp13 \ .exe 按任意鍵繼續。 。 。 'C:\Potico \ portico-1.0.2 \ examples \ cpp \ cpp13 \ 2'不被識別爲內部命令或外部可操作程序或批處理文件 Terminated - Normal – David 2013-02-15 10:50:31

回答

0

我修復了其他一些小的語法錯誤,例如用%1代替%1%併爲您的call blah\blah\confvarsC.bat行添加引號。還有一些其他潛在的問題,如果不知道腳本期望作爲參數或查看示例用法,我無法修復這些問題。我用!!!!!!評論標記了那些。

@echo off 

rem ########################### 
rem # implementation/version # 
rem ########################### 


rem ################################ 
rem # check command line arguments # 
rem ################################ 
:checkargs 
if #%1==# goto usage 
if #%2==# goto usage 


rem ####################### 
rem # test for JAVA_HOME # 
rem ####################### 
if "%JAVA_HOME%"=="" goto nojava 
goto rtihometest 

:nojava 
echo ERROR Your JAVA_HOME environment variable is not set! 
goto usage 

rem ####################### 
rem # test for RTI_HOME # 
rem ####################### 
:rtihometest 
call "C:\Arquivos de programas\Portico\portico-1.0.2\etc\confvarsC.bat" 
if not "%RTI_HOME%"=="" goto execute 


rem ############################################ 
rem ### (target) execute ####################### 
rem ############################################ 
:execute 

rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
rem !!!! SHIFT is useful if you have more than !!!! 
rem !!!! 9 arguments. Otherwise, there's no  !!!! 
rem !!!! reason to use it. After this, I can't !!!! 
rem !!!! tell whether you expect %2 to be the !!!! 
rem !!!! second script argument or the third. !!!! 
rem !!!! -- rojo         !!!! 
rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 

SHIFT 
set PATH=%JAVA_HOME%\jre\bin\client;%RTI_HOME%\bin;%PATH% 
set RTI_FEDDIR=C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\ 
set EXEC=C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\ 


if "%0"=="m" goto exec1 

rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
rem !!!! Shouldn't there be some sort of !!!!! 
rem !!!! "else goto" statement here? As !!!!! 
rem !!!! the script runs now, it will goto !!!!! 
rem !!!! exec1 regardless of whether  !!!!! 
rem !!!! "%0"=="m" -- rojo     !!!!! 
rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 


:exec1 
echo %EXEC%%1.cpp 
pause 
"%EXEC%%1.cpp" %2 
goto finish 


:usage 
echo usage: executePortico.bat [model] [nome modelo] 
goto err 

:err 
echo Terminated - Error 
goto end 

:finish 
echo Terminated - Normal 

:end 
+0

看看我做了什麼: 1 - 在命令提示符下: C:\ Portico \ portico-1.0.2 \ exec> executePortico.bat main C:\ Portico \ portico-1.0.2 \ examples \ cpp \ cpp13 \ main.exe 按任意鍵繼續...... 錯誤[main] portico.lrc:Fed文件不存在:file = file:/ C:/Portico/portico-1.0.2/exec/testfom.fed org.portico.lrc.compat .JCouldNotOpenFED:Fed文件不存在:file = file:/ C:/Portico/portico-1.0.2/exec/testfom.fed 如果我把文件executePortico.bat放在C:\ Portico \ p ortico-1.0.2 \ examples \ cpp \ cpp13,所以這種方式有效。 – David 2013-02-18 11:28:11

相關問題