Solved Why does this return with echo off?

December 8, 2015 at 17:03:52
Specs: Windows 10
:LOADING
setlocal enabledelayedexpansion
set load=%load%!!!!!!!
title Loading...
cls
echo *************** PIP-OS(R) V0.0.0.6 ***************
echo Login
echo --------------------------------------------------
echo.
echo.
echo Username : %unamel%
echo Password : %passwordl%
echo.
echo.
echo Logging in...
echo ===================================
echo !load!
echo ===================================
echo Please Wait...
echo.
echo.
ping localhost -n 2 >nul
set/a loadnum2=%loadnum2% +1
if %loadnum2%==5 goto menu
goto LOADING

it is part of a much larger batch file but everything else is fine aside from the fact that !load! returns with echo off even though when run in a seperate file under the same context it works just fine I'm new to working with cmd and this is quite troubling

See More: Why does this return with echo off?

Report •


✔ Best Answer
December 9, 2015 at 02:14:26
Use !load! instead of %load%

:LOADING
setlocal enabledelayedexpansion
set load=!load!^^!^^!^^!^^!^^!^^!^^!
title Loading...
cls
echo *************** PIP-OS(R) V0.0.0.6 ***************
echo Login
echo --------------------------------------------------
echo.
echo.
echo Username : %unamel%
echo Password : %passwordl%
echo.
echo.
echo Logging in...
echo ===================================
echo !load!
echo ===================================
echo Please Wait...
echo.
echo.
ping localhost -n 2 >nul
set/a loadnum2=%loadnum2% +1
if %loadnum2%==5 goto menu
goto LOADING

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)



#1
December 8, 2015 at 17:41:25
Because %load% is empty.

You have enabled delayed expansions, which means that !'s need to be escaped. This is done by adding ^^ before the exclamation mark. Note that most characters are escaped by adding just one ^, but since delayed expansions are enabled, the "!" is used for denoting variables, so it needs to be escaped twice in order to be treated as a regular character.

This should work:

set load=%load%^^!^^!^^!^^!^^!^^!^^!

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)

message edited by RainBawZ


Report •

#2
December 8, 2015 at 19:20:45
I agree with RainBawZ, set load=%load%^^!^^!^^!^^!^^!^^!^^! has to work. but i remember while i did batch i added one ^ not two and it worked too. i also know about the fact that RainBawZ mentioned, but never tried it.

Report •

#3
December 9, 2015 at 01:01:10
It does cause it to load but, it does not produce the same effect as before. that being it was a loading bar. any idea how to make it move across the screen again?

Report •

Related Solutions

#4
December 9, 2015 at 01:34:19
Use !load! instead of %load% when adding a new ! to the variable

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)


Report •

#5
December 9, 2015 at 01:59:17
it returns with echo off using

:LOADING
setlocal enabledelayedexpansion
set load=%load%^^!^^!^^!^^!^^!^^!^^!
title Loading...
cls
echo *************** PIP-OS(R) V0.0.0.6 ***************
echo Login
echo --------------------------------------------------
echo.
echo.
echo Username : %unamel%
echo Password : %passwordl%
echo.
echo.
echo Logging in...
echo ===================================
echo %load%
echo ===================================
echo Please Wait...
echo.
echo.
ping localhost -n 2 >nul
set/a loadnum2=%loadnum2% +1
if %loadnum2%==5 goto menu
goto LOADING

if it were that simple i wouldn't have asked :/


Report •

#6
December 9, 2015 at 02:14:26
✔ Best Answer
Use !load! instead of %load%

:LOADING
setlocal enabledelayedexpansion
set load=!load!^^!^^!^^!^^!^^!^^!^^!
title Loading...
cls
echo *************** PIP-OS(R) V0.0.0.6 ***************
echo Login
echo --------------------------------------------------
echo.
echo.
echo Username : %unamel%
echo Password : %passwordl%
echo.
echo.
echo Logging in...
echo ===================================
echo !load!
echo ===================================
echo Please Wait...
echo.
echo.
ping localhost -n 2 >nul
set/a loadnum2=%loadnum2% +1
if %loadnum2%==5 goto menu
goto LOADING

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)


Report •

#7
December 9, 2015 at 02:18:12
your a great help thanks alot! ^-^

Report •

Ask Question