|Like I tried to tell you in the other thread the spaces you are using around your set statements are not ignored by cmd.|
set fun = %errorlevel%
echo [%fun%] - Brackets should be empty
echo [%fun %] - Look the spaces are part of the variable name and it's content.
Stop putting spaces around the "=" sign with the set command and you code may have a chance of working.