このbatファイルが呼び出し元のbatファイルに戻らないのはなぜですか?


1
K:\bin>type get_resolution.bat  
i_view.bat "%1" /info=info.txt  
echo after get_resolution  
type info.txt | find "Resolution"  

K:\bin>type i_view.bat  
echo %*  
echo %errorlevel%  
echo after i_view  

K:\bin>get_resolution.bat input.jpg  

K:\bin>i_view.bat "input.jpg" /info=info.txt  

K:\bin>echo "input.jpg" /info=info.txt  
"input.jpg" /info=info.txt  

K:\bin>echo 0  
0  

K:\bin>echo after i_view  
after i_view  

K:\bin>  

「get_resolutionの後」がないのはなぜですか?

回答:


2

callコマンドを使用します。このコマンドを使用しないと、バッチファイルは現在のファイルを「置換」します。

スクリプトにを入れcall i_view.bat "%1" /info=info.txtます。

cmd.exe /k 同等です。


のヘルプテキストの一部を次に示しますcall /?

Calls one batch program from another.

CALL [drive:][path]filename [batch-parameters]

  batch-parameters   Specifies any command-line information required by the
                     batch program.

If Command Extensions are enabled CALL changes as follows:

CALL command now accepts labels as the target of the CALL.  The syntax
is:

    CALL :label arguments

A new batch file context is created with the specified arguments and
control is passed to the statement after the label specified.  You must
"exit" twice by reaching the end of the batch script file twice.  The
first time you read the end, control will return to just after the CALL
statement.  The second time will exit the batch script.  Type GOTO /?
for a description of the GOTO :EOF extension that will allow you to
"return" from a batch script.
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.