Advertisement
Aacini

T2H - HelpToTextToHtml.txt

Dec 9th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 KB | None | 0 0
  1. Windows-DOS Commands Help
  2. ==Screen|:- Commands for Screen control==
  3. TITLE COLOR CLS CHCP MODE GRAFTABLE
  4. ==File|:- Commands to manage Files==
  5. ===Text files|:- Process the contents of Text files===
  6. TYPE MORE PRINT FIND FINDSTR SORT FC COMP EDIT EDLIN DEBUG
  7. ===All files|:- Process files as Entire units===
  8. DIR TREE REN COPY XCOPY ROBOCOPY MOVE REPLACE MKLINK DEL ATTRIB CACLS ICACLS MAKECAB EXPAND PACKAGER FSUTIL
  9. ==Directory|:- Commands to create, change and remove Directories==
  10. MD CD PUSHD POPD RD SUBST APPEND MKLINK MOUNTVOL
  11. ==Disk|:- Commands for Disk maintenance==
  12. FORMAT LABEL VOL CHKDSK CHKNTFS CONVERT COMPACT CIPHER RECOVER DISKCOPY DISKCOMP
  13. ==Process|:- Commands to execute, list and cancel Programs==
  14. START RUNAS AT SCHTASKS TASKLIST TASKKILL TSKILL TSSHUTDN SHUTDOWN PATH ASSOC FTYPE SETVER
  15. ==Comms|:- Commands to manage Communications==
  16. MSG TELNET TFTP PING PATHPING NET OPENFILES DRIVERQUERY GPRESULT
  17. ==Batch|:- Values, modifiers and commands for Batch files==
  18. ===Char:Characters|:- Special Characters used in commands and Batch files===
  19. [code]Characters
  20. ,;= Separators for command parameters and FOR sets, besides spaces and tabs.
  21. *? Wild-card characters that matches several file and directory names.
  22. @ Placed before a command does not echo it even if ECHO is ON: @ECHO OFF
  23.  
  24. > Send command output to a new disk file: COMMAND > OUTPUT.TXT
  25. The DOS waste bin is called NUL: COPY *.* DEST > NUL
  26. >> Append command output if the file exists: COMMAND >> APPEND.TXT
  27. 2> Send error messages to a disk file: COMMAND 2> ERRORS.TXT
  28. 2>&1 Send error messages to the same file of >: COMMAND > ALL.TXT 2>&1
  29. < Get command input from a disk file: COMMAND < INPUT.TXT
  30.  
  31. & COM1 & COM2 is the same as execute COM1 and then execute COM2
  32. | COM1 | COM2 is equivalent to: COM1 > F.TMP & COM2 < F.TMP & DEL F.TMP
  33. but both commands run in parallel (in different cmd.exe contexts).
  34. && COM1 && COM2 is the same as: COM1 & IF NOT ERRORLEVEL 1 COM2
  35. || COM1 || COM2 is the same as: COM1 & IF ERRORLEVEL 1 COM2
  36. () Group together several commands: ( COM1 & COM2 & COM3 ) > THREEOUTS.TXT
  37. TESTCOM && ( COM1THEN & COM2THEN ) || ( COM1ELSE & COM2ELSE & COM3ELSE )
  38.  
  39. % Expand the value of Batch parameters (%1 ...), FOR parameters (%%A ...)
  40. and Batch variables (%VAR%); %* always expands to all Batch parameters.
  41. A FOR command typed in the command-line must use a single percent char.
  42. ! Additional way (Delayed Expansion) to take the value of a variable: !VAR!
  43.  
  44. ^ Insert, not process, the next special character: ECHO ^%VAR^% is %VAR%
  45. An exclamation mark can not be inserted in a Batch file this way
  46. if Delayed !VARIABLE! Expansion is Enabled.
  47. " Enclose a string that will not be processed as special characters:
  48. SET "HEADER=<ONE|TWO|THREE>"
  49. Exclamation marks are always processed if Delayed Expansion is Enabled.
  50. [/code]
  51. ===Vars:Variables|:- Normal and delayed expansions, and dynamic Variables===
  52. [code]Variables
  53. %var% Expand the value of Var variable: ECHO Var value is: %Var%
  54.  
  55. %var:old=new% Substitute all occurrences of Old (case insensitive) by New
  56. in Var expansion. If Old start with asterisk, substitute from
  57. beginning of Var value until first occurrence of Old.
  58.  
  59. %var:~pos,size% Substring of Var from 0-based Position by Size characters; if
  60. Pos or Size are negative, indicate a backwards position from
  61. end. If Size is omitted, the substring ends at last character.
  62.  
  63. A variable may be enclosed in exclamation-marks instead of percent-signs to
  64. expand its value in Delayed Variable Expansion that happens after the normal
  65. (percent-signs) expansion, so both types may be combined. This feature allows
  66. some advanced manipulations, like multi-dimensional arrays. For example:
  67.  
  68. SET /P OLD=Enter old part:
  69. SET /P NEW=Enter new part:
  70. SET CHANGED=!ORIGINAL:%OLD%=%NEW%!
  71.  
  72. SET /P POS=Enter position:
  73. SET /P SIZE=Enter size:
  74. SET SUBSTRING=!VAR:~%POS%,%SIZE%!
  75.  
  76. SET VECTOR[1]=Element One
  77. SET VECTOR[2]=Element Two, etc...
  78. SET I=set subscript value in some way
  79. ECHO The value of element %I% is: !VECTOR[%I%]!
  80.  
  81. If there are several commands in one line or enclosed in parentheses, %normal%
  82. expansions are performed just once before the line or block is executed, but
  83. !delayed! expansions are performed each time that the commands are executed:
  84.  
  85. SET VAR=Old value
  86. SET VAR=New value & ECHO Previous value: %VAR%, modified in this line: !VAR!
  87.  
  88. In order to use Delayed Expansion, insert this command at beginning of Batch file:
  89.  
  90. SETLOCAL ENABLEDELAYEDEXPANSION
  91.  
  92. Dynamic variables (don't define any variable with same name):
  93.  
  94. %CD% Expands to the current directory string.
  95. %DATE% Expands to current date using same format as DATE command.
  96. %TIME% Expands to current time using same format as TIME command.
  97. %RANDOM% Expands to a random decimal number between 0 and 32767.
  98. %ERRORLEVEL% Expands to the current ERRORLEVEL value.
  99. [/code]
  100. ===Mods:Modifiers|:- Expansion Modifiers for replaceable parameters===
  101. [code]Modifiers
  102. The following modifiers works in FOR command parameters (letters) and
  103. Batch file parameters (digits); the modifiers may not be used with %*
  104. Letter (%A..%Z) and digit (%0..%9) Parameters are represented below by: %P
  105.  
  106. %P Expands P
  107. %~P Expands P removing any surrounding quotes (").
  108. %~fP Expands P to a Fully qualified path name.
  109. %~dP Expands P to a Drive letter only (including the colon).
  110. %~pP Expands P to a Path only (that ends in backslash).
  111. %~nP Expands P to a file Name only.
  112. %~xP Expands P to a file eXtension only (including the dot).
  113. %~sP Expands P using Short 8.3 names.
  114. %~aP Expands P to file Attributes.
  115. %~tP Expands P to date/Time of file.
  116. %~zP Expands P to siZe of file.
  117.  
  118. %~$var:P Special case: Searches current P file name in the directories listed
  119. in Var Batch variable and expands the parameter to the fully qualified
  120. path name of the first one found, or an empty string if not found.
  121. The directories must be separated by semicolons, like in PATH variable.
  122.  
  123. Several modifiers may be combined in the same parameter: %~ntzP
  124.  
  125. For example, the following command take the path of the running Batch file:
  126. SET MYPATH=%~p0
  127. [/code]
  128. ===Error:Errorlevel|:- Description of the Errorlevel value===
  129. [code]Errorlevel
  130. When most commands and programs ends they return an exit code, called
  131. ERRORLEVEL, that is a 32-bits signed integer value. The MS-DOS standard
  132. specify that a program return an ERRORLEVEL of zero if successfully ends,
  133. but the value is greater than zero if the program ends because an error.
  134.  
  135. The following DOS commands, among others, return useful ERRORLEVEL values:
  136. TYPE return 0 if the file was typed, return 1 if File not found.
  137. COPY return 0 if file(s) was copied, return 1 if File not found.
  138. FIND return 0 if the string was found, return 1 otherwise (also FINDSTR).
  139. FC return 0 if both files matched, return 1 otherwise.
  140. CD return 0 if directory was changed, return 1 if Dir not exists.
  141. VOL return 0 if volume was displayed, return 1 if invalid Drive.
  142. TIME return 0 if given time is correct, return 1 if invalid Time (also DATE).
  143. SET /P return 1 if line read is empty, otherwise NOT change ERRORLEVEL.
  144. SET /A return not zero if expression is wrong, otherwise NOT change ERRORLEVEL.
  145. VERIFY return 0 if parameter is ON or OFF, return 1 otherwise.
  146. VER always return 0.
  147.  
  148. The following internal DOS commands, among others, does not modify the
  149. current ERRORLEVEL value: CLS, REM, ECHO, PAUSE, SHIFT, GOTO, SET var=value
  150. All .COM and .EXE executable files modify the ERRORLEVEL when they ends.
  151.  
  152. To check the ERRORLEVEL use "IF ERRORLEVEL Number Command" that execute the
  153. Command if the ERRORLEVEL value is greater than or equal to the given Number;
  154. to test for several values, place the IF's in descending ERRORLEVEL order:
  155. FOR /L %%I IN (6,-1,1) DO IF ERRORLEVEL %%I GOTO ERROR%%I
  156.  
  157. A Batch file may directly get the ERRORLEVEL value via the %ERRORLEVEL%
  158. dynamic variable, for example: IF %ERRORLEVEL% EQU 3 GOTO ERROR3
  159.  
  160. A Batch file may return an useful ERRORLEVEL value via "EXIT /B exitCode" command.
  161. This is the one-line SETERRORLEVEL.BAT file that allows to set the ERRORLEVEL
  162. to any value given in its parameter: @EXIT /B %1
  163. For example: CALL SETERRORLEVEL 123
  164. [/code]
  165. ===Commands|:- Commands used in Batch files===
  166. REM ECHO PAUSE CHOICE SHIFT GOTO IF FOR SET SETLOCAL ENDLOCAL CALL CMD EXIT
  167. ==Various|:- Commands that not fit in previous subdivisions==
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement