Passing the result of one batch file to another?
This line will do what you want:
for /F "tokens=3" %v in ('BAT1.bat') do call BAT2.bat %v
What this line does is call BAT1.bat
, then parses its output using the parameters specified after /F
. Specifically, it "tokens=3"
tells the shell to take the third token and place it in a variable. Then it is called BAT2.bat
with a variable as a parameter .
Assuming you are going to use this in a batch file, you will need to double the percentage signs:
for /F "tokens=3" %%v in ('BAT1.bat') do call BAT2.bat %%v
For more information enter
for /?
from the command line
source to share
Make a type call Bat1.bat | Bat2.bat
, then enter the code at the beginning of bat2.bat to get the substring you want.
If you can't touch bat2.bat , create a bat3.bat dedicated to configuring the "Login: 7o5g4cika" credentials to "7o5g4cika" and call for example:Bat1.bat | Bat3.bat | Bat2.bat
source to share