I'd like to use a batch file to call a different batch file that is in a sub directory. For instance, if my file system look as follows:
MainFolder
main.bat FirstDirectory SecondDirectory foo.batThen main.bat might look something like this:
开发者_如何学Goecho on
REM This lines tells the user what this bat file is doing
call ant
call \SecondDirectory\foo.bat
I'm looking for a one line solution which I think does not exist. Unfortunately I don't always want to do this with a batch file and want to do it directly from the command line.
You can indeed call a batch file from another batch file using the call
command. As @Blorgbeard states, the issues is the leading backslash \
. Removing it indicates SecondDirectory
is relative to the current working directory.
call SecondDirectory\foo.bat
A word of caution: the call
command essentially inserts called code in at run time. Be careful to avoid variable name collisions.
精彩评论