99
|
1 |
-*- outline -*-
|
|
2 |
|
215
|
3 |
* Variables.
|
|
4 |
|
|
5 |
Variable name start with letter and underscore, next chars can be letter,
|
|
6 |
number and underscore. Variable name is case insensitive.
|
|
7 |
|
|
8 |
** List of variables.
|
|
9 |
|
|
10 |
cmd> set
|
|
11 |
...
|
|
12 |
VAR=VALUE
|
|
13 |
|
|
14 |
** Getting.
|
|
15 |
|
|
16 |
Write %VAR% in place where you want insert variable VAr value.
|
|
17 |
|
|
18 |
** Setting.
|
|
19 |
|
|
20 |
cmd> set /p VAR=VALUE
|
|
21 |
|
|
22 |
VAR is variable name, VALUE is value.
|
|
23 |
|
|
24 |
** Deleting.
|
|
25 |
|
|
26 |
cmd> set VAR=
|
|
27 |
|
|
28 |
VAR is variable name.
|
|
29 |
|
|
30 |
*** Input from user.
|
|
31 |
|
|
32 |
cmd> set /p VAR=PROMPT
|
|
33 |
|
|
34 |
VAR is variable name, PROMPT is displayed prompt.
|
|
35 |
|
|
36 |
*** Input from file.
|
|
37 |
|
|
38 |
cmd> set /p VAR=<FILE
|
|
39 |
|
|
40 |
VAR is variable name, FILE is file name. Sfter executing VAR contain first
|
|
41 |
line from FILE.
|
|
42 |
|
99
|
43 |
* CMD tricks.
|
|
44 |
|
|
45 |
$ set /p TOOLOUTPUT= < temp.txt
|
|
46 |
|
|
47 |
$ for /f "tokens=*" %%i in ('%~dp0sometool.exe') do set TOOLOUTPUT=%%i
|
|
48 |
|
|
49 |
$ for /f "tokens=1 delims=" %%s in (users.txt) do (echo %%S & command "%%S") >> outputfile.txt
|