windows 无法从另一个内部调用 .bat 文件 - “未识别为内部或外部命令”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2977215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
can't call .bat file from within another - "not recognized as an internal or external command" error
提问by splatback
i tried looking at the other questions regarding this, but no go. i've tried a straight call to the other bat file ("otherBat.bat," for instance), a "call" command, and even a "start" command. all of these are failing though, and i'm at a loss as to why. both .bat files are within the same folder, and i'm not changing directories, so i don't know what the problem is...
我尝试查看有关此的其他问题,但没有去。我试过直接调用另一个 bat 文件(例如“otherBat.bat”)、“call”命令,甚至是“start”命令。尽管如此,所有这些都失败了,我不知道为什么。两个 .bat 文件都在同一个文件夹中,我没有改变目录,所以我不知道问题是什么......
any help on this would be much appreciated ^_^
对此的任何帮助将不胜感激^_^
edit: sorry, here's the code :)
编辑:对不起,这是代码:)
primary.bat:
主要.bat:
echo Test run...enter variable1
set /p var1=:
echo Test run...enter variable2
set /p var2=:
call other.bat %var1% %var2%
pause
other.bat:
其他.bat:
echo Working!
pause
回答by ashurexm
You should either cd to the current directory in your first batch file or call the second batch file by full path.
您应该 cd 到第一个批处理文件中的当前目录,或者通过完整路径调用第二个批处理文件。
回答by DVK
Is the second .bat file in your path? What happens if you change your first .bat file to call it using an absolute path?
您的路径中是否有第二个 .bat 文件?如果您更改第一个 .bat 文件以使用绝对路径调用它,会发生什么情况?
回答by marcdahan
use the absolute path :
使用绝对路径:
::prototype
CALL [drive:][path]filename [parameters]
::example
call C:\Users\theUserName\path-to-your-file\the-file-name.bat %your-variables-to-pass%