Working with CMD variables.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 27 Nov 2022 18:41:07 +0200
changeset 2539 742921adf64c
parent 2538 1f827ee55f7c
child 2540 d699ee7377a4
Working with CMD variables.
cmd.rst
--- a/cmd.rst	Sun Jul 03 12:49:17 2022 +0300
+++ b/cmd.rst	Sun Nov 27 18:41:07 2022 +0200
@@ -40,56 +40,37 @@
 http://msdn.microsoft.com/en-us/library/ms880421.aspx
   Parsing C Command-Line Arguments
 
-Variables.
-==========
+Variables
+=========
 
 Variable name start with letter and underscore, next chars can be letter,
 number and underscore. Variable name is case insensitive.
 
-List of variables.
-------------------
-::
+List variables::
 
-  cmd> set
+  cmd# set
   ...
   VAR=VALUE
 
-Getting.
---------
-
-Write %VAR% in place where you want insert variable VAr value.
+Use syntax ``%NAME%`` to expand ``NAME`` value.
 
-Setting.
---------
-::
-
-  cmd> set /p VAR=VALUE
+Use ``set`` command to define environment variable (``/p`` is with a user input, ``/a`` for
+arithmetic expressions)::
 
-Deleting.
----------
-::
-
-  cmd> set VAR=
+  set NAME=VALUE
+  set /p PASS="Enter password: "
+  set /a NUM="1+2"
 
-Input from user.
-----------------
-::
-
-  cmd> set /p VAR=PROMPT
+To delete env variable set it to empty value::
 
-VAR is variable name, PROMPT is displayed prompt.
+  set VAR=
 
-Input from file.
-----------------
-::
+To load first line from a file into a variable::
 
   cmd> set /p VAR=<FILE
 
-VAR is variable name, FILE is file name. Sfter executing VAR contain first
-line from FILE.
-
-CMD tricks.
-===========
+CMD tricks
+==========
 ::
 
   $ set /p TOOLOUTPUT= < temp.txt