i want to call a batch file from another batch file and also want to pass a variable to it. lets say i want to call b.bat from a.bat. my b.bat copies files. so while calling it from a.bat , i want to pass the path of the destination folder to b.bat.<br /> well to b more clear, the destination path will b entered by user, so it will b stored in a variable say 'x'. how do i pass the path now?Answer1:
rem --- a.bat ---
set /p TargetPath=Please enter destination path:
call b.bat "%TargetPath%"
rem --- b.bat ---
echo Copying to: %~1
As an alternative, you can simply use %TargetPath% in b.bat: environment variables are inherited by subprocesses. But passing a parameter explicitly is probably better from the flexibility and supportability point of view.