How to set a variable for the current OS session only
问题 setx permanently modifies environment variables. set only makes variables available during batch script duration. Is there any way to set a variable in order to hold its value until the system is restarted? E.g. in my batch file, I'm checking if the variable is set like this: if %MYVAR% == 1 ( <block> ) 回答1: @ECHO Off IF NOT EXIST q25244121.org GOTO done :: reset to original FOR /f "tokens=1*delims==" %%a IN (q25244121.org) DO ( IF DEFINED %%a FOR /f "tokens=1*delims==" %%p IN ('set %%a') DO