简体   繁体   English

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

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

I have a batch file a.bat that effectively looks like this: 我有一个批处理文件a.bat ,它实际上看起来像这样:

call some.bat

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

call subfolder\other.bat

And the other.bat in subfolder effectively looks like this: 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

So in the first file ( a.bat ), I call another batch file in the same folder and some xsl scripts in the same folder that write xml files into the same folder. 因此,在第一个文件( a.bat )中,我在同一文件夹中调用另一个批处理文件,并在同一文件夹中调用一些xsl脚本,这些脚本将xml文件写入同一文件夹。 From the first batch script ( a.bat ) I'd like to call the subfolder\\other.bat . 在第一个批处理脚本( a.bat )中,我想调用subfolder\\other.bat However, when I do that, it fails to call the yet_another_batch.bat in subfolder and also the xsl scripts in subfolder and it doesnt find the saxon9he.jar. 然而,当我做到这一点,它不能称之为yet_another_batch.batsubfolder ,并在XSL脚本subfolder和它没有找到saxon9he.jar。

What's the correct way to do this? 正确的方法是什么? Do I have to add the folder name to all the files referenced in the subfolder\\other.bat ? 我是否必须将文件夹名称添加到subfolder\\other.bat引用的所有文件中? Seems a little cumbersome. 似乎有点麻烦。 I'm on Windows 7, if that changes anything. 我在Windows 7上,如果一切有变。

Add two lines lines to other.bat like this: 将两行代码添加到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

Using pushd , other.bat will execute it's commands from it's own folder. 使用pushd ,other.bat将在其自己的文件夹中执行命令。 popd sets it back so the directory will not be changed when you return in a.bat popd将其设置回原来的位置,因此当您返回a.bat时目录不会更改

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

相关问题 循环调用另一个批处理文件的批处理文件 - Looping a batch file that calls another batch file 批处理文件调用另一个批处理以特定方式循环启动文件 - Batch file Calls another batch to launch a file in a specific way looping 从批处理文件调用PowerShell失败 - Calling PowerShell from a batch file fails 从另一个批处理文件在路径中使用空格调用Win Batch文件 - Calling Win Batch file with Whitespace in Path from another Batch file Windows Batch,用于调用另一个批处理时的循环和文件属性 - Windows Batch, for loop and file attributes while calling another batch 从Windows批处理文件中读取文件并调用另一个.bat - Reading a file and calling another .bat from within a Windows batch file Windows 批处理文件 - 清除另一个批处理文件 - Windows Batch File - Clearing another batch file 使用其他批处理文件停止批处理文件? - Stop a batch file using another batch file? 从另一个批处理文件调用该批处理文件时,批处理文件中的复制命令未得到执行,但是当我双击时,该命令正在执行 - copy command in batch file is not getting executed when calling the batch file from another batch file, but is getting executed when i double click 从不同目录中的另一个批处理文件调用批处理文件 - 找不到资源 - Calling a batch file from another batch file in different directory - resources not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM