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 off
cls
set "Build=0"
call:FindString "MAINALGO"
IF /I "%Build%" == "MAINALGO" (
echo "start job on MainAlgo"
) else (
call:FindString "DRSITEALGO"
echo build value %Build%
IF /I "%Build%" == "DRSITEALGO" (
echo "start job on secondAlgo"
) else (
echo "sth wrong"
)
)
:FindString
echo funtioninput %~1
find /I /C "%~1" version.property
if %errorlevel%==1 (
echo "errorlevel 1"
set "Build=0"
)
if %errorlevel%==0 (
echo "errorlevel 0"
set "Build=%~1"
echo build value in function %Build%
)
:end
The content in version.property is below
DRSITEALGO
The problem is I found that when the program is executed it looks like the below line work incorrectly. The variable Build is not set to the value in "%~1"
set "Build=%~1"
I got the below as output
funtioninput MAINALGO
---------- VERSION.PROPERTY: 0
"errorlevel 1"
funtioninput DRSITEALGO ---> the %~1 show the correct value, DRSITEALGO
---------- VERSION.PROPERTY: 1
"errorlevel 0"
build value in function 0 ---> here is wrong! the Build variable somehow didn't get updated, it suppose to be DRSITEALGO
build value 0
"sth wrong"
Not sure that I have to set anything to make it works??