How do I solve delayed variable assignment?
(I'm making the term delayed variable assignment up, because it seems like a reasonable descriptive phrase).
Example Batch Script Code script.bat:
@echo off
set mylocation=%CD%
echo mylocation %mylocation%
echo CD %CD%
Actual Output
C:> script.bat
mylocation
CD C:\
C:>
What I want it to do (or thought it would do)
C:> script.bat
mylocation C:\
CD C:\
C:>
Edit (changed): If I echo %mylocation% in command prompt after the script ends it has a value.
C:>echo %mylocation%
C:\
C:>
Edit: This is the original Code, and you can view the youtube video https://youtu.be/jQzEFD3yISA - where I try to show as much detail as possible so that, everything is exact.
@echo off
set natasha_command=%1
if %natasha_command% == start (
set mylocation=%CD%
echo mylocation %mylocation%
echo CD %CD%
)
goto :eof