繁体   English   中英

调用另一个批处理文件的调用批处理文件失败

[英]calling batch file that calls yet another batch file fails

我有一个批处理文件a.bat ,它实际上看起来像这样:

call some.bat

java -cp "saxon9he.jar" net.sf.saxon.Transform  abc.xml des.xsl > des.xml

call subfolder\other.bat

subfolderother.bat实际上看起来像这样:

call yet_another_batch.bat

java -cp "../saxon9he.jar" net.sf.saxon.Transform any.xml try.xsl > try.xml
java -cp "../saxon9he.jar" net.sf.saxon.Transform ../some.xml test.xsl

因此,在第一个文件( a.bat )中,我在同一文件夹中调用另一个批处理文件,并在同一文件夹中调用一些xsl脚本,这些脚本将xml文件写入同一文件夹。 在第一个批处理脚本( a.bat )中,我想调用subfolder\\other.bat 然而,当我做到这一点,它不能称之为yet_another_batch.batsubfolder ,并在XSL脚本subfolder和它没有找到saxon9he.jar。

正确的方法是什么? 我是否必须将文件夹名称添加到subfolder\\other.bat引用的所有文件中? 似乎有点麻烦。 我在Windows 7上,如果一切有变。

将两行代码添加到other.bat中,如下所示:

pushd "%~dp0"
call yet_another_batch.bat

java -cp "../saxon9he.jar" net.sf.saxon.Transform any.xml try.xsl > try.xml
java -cp "../saxon9he.jar" net.sf.saxon.Transform ../some.xml test.xsl
popd

使用pushd ,other.bat将在其自己的文件夹中执行命令。 popd将其设置回原来的位置,因此当您返回a.bat时目录不会更改

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM