To set an environment variable named TEST^1, type:
set testVar=test^^1
To set an environment variable named TEST&1, type:
set testVar=test^&1
Set sets the variable value as everything following the equals sign (=). If you type:
set testVar="test^1"
You get the following result:
testVar="test^1"
To set an environment variable named INCLUDE so that the string C:\Inc (the \Inc directory on drive C) is associated with it, type:
set include=c:\inc
You can then use the string C:\Inc in batch files by enclosing the name INCLUDE with percent signs (%). For example, you might include the following command in a batch file so that you can display the contents of the directory associated with the INCLUDE environment variable:
dir %include%
When this command is processed, the string C:\Inc replaces %include%.
You can also use set in a batch program that adds a new directory to the PATH environment variable. For example:
@echo off
rem ADDPATH.BAT adds a new directory
rem to the path environment variable.
set path=%1;%path%
set
When command extensions are enabled (that is, the default) and you run set with a value, it displays the variables that match that value. For example, if you type setp at the command prompt, you get the following results:
Path=C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86PROCESSOR_IDENTIFIER=x86
Family 6 Model 8 Stepping 1, GenuineIntel
PROCESSOR_LEVEL=6PROCESSOR_REVISION=0801
ProgramFiles=C:\Program Files
PROMPT=$P$G