1.

Solve : set command doesn't work with if as it says on the explanation?

Answer»

In the explanation of the set command in the cmd it says to write a program like this:

set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @ECHO If you see this, it worked
)

cause if you'll write "%var%"=="after" (it will take the before and compare to after)
but even when i write it like this the output i get(with echo on) is:

C:\>if "before" ==
"before" (
set VAR=after
if "!VAR!" == "after"
)

it doesn't recognize the value of the !var! , why is that?

another question, can i set a permanent variable that won't disapear after i close cmd, like windir,cd,errorlevel and such...Quote from: kyou8 on April 26, 2011, 04:32:32 AM

it doesn't recognize the value of the !var! , why is that?

TRY reading the entire help blurb, especially the part about delayed environment variable expansion.

Quote from: kyou8 on April 26, 2011, 04:32:32 AM
another question, can i set a permanent variable that won't disapear after i close cmd, like windir,cd,errorlevel and such...

Not thru batch code. You can USE any Windows Script language or use the GUI by RIGHT clicking on My Computer==>Properties==>Advanced==>Environmental Variables.

By the way, cd, errorlevel, and such are context DRIVEN and do not have permanent values. Windir was set when the OS was installed, why do you want to change it?

Quote from: kyou8 on April 26, 2011, 04:32:32 AM
another question, can i set a permanent variable that won't disapear after i close cmd

yes, use SETX.


Discussion

No Comment Found