cmd.rst
changeset 2228 837f1337c59b
parent 1912 8b81a8f0f692
child 2539 742921adf64c
equal deleted inserted replaced
2227:1e9323e7ec88 2228:837f1337c59b
     7    :local:
     7    :local:
     8 
     8 
     9 Quoting.
     9 Quoting.
    10 ========
    10 ========
    11 
    11 
    12  * Arguments are delimited by white space, which is either a space or a tab.
    12 * Arguments are delimited by white space, which is either a space or a tab.
    13  * A string surrounded by double quotation marks is interpreted as a single
    13 * A string surrounded by double quotation marks is interpreted as a single
    14    argument.
    14   argument.
    15  * A double quotation mark preceded by a backslash, \", is interpreted as a
    15 * A double quotation mark preceded by a backslash, \", is interpreted as a
    16    literal double quotation mark.
    16   literal double quotation mark.
    17  * Backslashes are interpreted literally, unless they immediately precede a
    17 * Backslashes are interpreted literally, unless they immediately precede a
    18    double quotation mark.
    18   double quotation mark.
    19  * If an even number of backslashes is followed by a double quotation mark,
    19 * If an even number of backslashes is followed by a double quotation mark,
    20    then one backslash (\) is placed in the argv array for every pair of
    20   then one backslash (\) is placed in the argv array for every pair of
    21    backslashes (\\), and the double quotation mark (") is interpreted as a
    21   backslashes (\\), and the double quotation mark (") is interpreted as a
    22    string delimiter.
    22   string delimiter.
    23  * If an odd number of backslashes is followed by a double quotation mark,
    23 * If an odd number of backslashes is followed by a double quotation mark,
    24    then one backslash (\) is placed in the argv array for every pair of
    24   then one backslash (\) is placed in the argv array for every pair of
    25    backslashes (\\) and the double quotation mark is interpreted as an escape
    25   backslashes (\\) and the double quotation mark is interpreted as an escape
    26    sequence by the remaining backslash, causing a literal double quotation
    26   sequence by the remaining backslash, causing a literal double quotation
    27    mark (") to be placed in argv.
    27   mark (") to be placed in argv.
    28  * In double quote mark need surround such chars::
    28 * In double quote mark need surround such chars::
    29 
    29 
    30      & < > [ ] { } ^ = ; ! ' + , ` ~ %
    30     & < > [ ] { } ^ = ; ! ' + , ` ~ %
    31 
    31 
    32    Also all this char can be escaped by ^ char.
    32   Also all this char can be escaped by ^ char.
    33  * Long line can be truncated by ^ char, in this case trailing white spaces
    33 * Long line can be truncated by ^ char, in this case trailing white spaces
    34    not allowed.
    34   not allowed.
    35  * To quote percent sign % before alpha char in batch file double it
    35 * To quote percent sign % before alpha char in batch file double it
    36    occurrences or plase in quotes::
    36   occurrences or plase in quotes::
    37 
    37 
    38      prog '%'HOME'%' "%"HOME"%" %%HOME%
    38     prog '%'HOME'%' "%"HOME"%" %%HOME%
    39 
    39 
    40   http://msdn.microsoft.com/en-us/library/ms880421.aspx
    40 http://msdn.microsoft.com/en-us/library/ms880421.aspx
    41                 Parsing C Command-Line Arguments
    41   Parsing C Command-Line Arguments
    42 
    42 
    43 Variables.
    43 Variables.
    44 ==========
    44 ==========
    45 
    45 
    46 Variable name start with letter and underscore, next chars can be letter,
    46 Variable name start with letter and underscore, next chars can be letter,
    79 
    79 
    80 VAR is variable name, PROMPT is displayed prompt.
    80 VAR is variable name, PROMPT is displayed prompt.
    81 
    81 
    82 Input from file.
    82 Input from file.
    83 ----------------
    83 ----------------
       
    84 ::
    84 
    85 
    85   cmd> set /p VAR=<FILE
    86   cmd> set /p VAR=<FILE
    86 
    87 
    87 VAR is variable name, FILE is file name. Sfter executing VAR contain first
    88 VAR is variable name, FILE is file name. Sfter executing VAR contain first
    88 line from FILE.
    89 line from FILE.
   107 =======
   108 =======
   108 
   109 
   109 Variable value and one line command string after expansion can not exceed 8191
   110 Variable value and one line command string after expansion can not exceed 8191
   110 characters for Windows XP and later and 2047 for Windows NT, Windows 2000.
   111 characters for Windows XP and later and 2047 for Windows NT, Windows 2000.
   111 
   112 
   112   http://support.microsoft.com/default.aspx?scid=kb;en-us;830473
   113 http://support.microsoft.com/default.aspx?scid=kb;en-us;830473
   113                 Command prompt (Cmd. exe) command-line string limitation
   114   Command prompt (Cmd. exe) command-line string limitation.
   114 
   115 
   115 How run cmd on 64-bit OS.
   116 How run cmd on 64-bit OS.
   116 =========================
   117 =========================
   117 
   118 
   118 From 64-bit process::
   119 From 64-bit process::
   123 From 32-bit process::
   124 From 32-bit process::
   124 
   125 
   125   %windir%\System32\cmd.exe (for 32-bit)
   126   %windir%\System32\cmd.exe (for 32-bit)
   126   %windir%\Sysnative\cmd.exe (for 64-bit)
   127   %windir%\Sysnative\cmd.exe (for 64-bit)
   127 
   128 
   128   http://msdn.microsoft.com/en-us/library/aa384187%28VS.85%29.aspx
   129 http://msdn.microsoft.com/en-us/library/aa384187%28VS.85%29.aspx
   129                 File System Redirector
   130   File System Redirector
   130 
   131