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...
any help on this would be much appreciated ^_^
开发者_如何学运维edit: sorry, here's the code :)
primary.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:
echo Working!
pause
You should either cd to the current directory in your first batch file or call the second batch file by full path.
Is the second .bat file in your path? What happens if you change your first .bat file to call it using an absolute path?
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%
cf the call documentation from ss64.com
Absolute path may be replaced with %~dp0\
, which means use current script's path instead of runtime context; in your case call %~dp0\other.bat %var1% %var2%
.
Had same issue when running as administrator from context menu – call
tried to execute batch file in System32 instead of parent BAT folder.
精彩评论