I have a simple batch script that will read the value in file version.property and perform a certain job my code is below
TITLE StartEODMaintenance
echo o
The %variables% are expanded when the command is parsed and the command if followed by a block is parsed at once. So when you set a variable in the block, its following usage (in echo here) has been expanded already and it results in showing the value that was valid before entering the block!
You need delayed expansion to read variable values at the moment when they are used, not parsed. First, issue the command:
setlocal EnableDelayedExpansion
Then refer to the variables modified earlier within the same block as !variable!.
if %errorlevel%==0 (
echo "errorlevel 0"
set "Build=%~1"
echo build value in function !Build!
)