![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-23 12:21 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » Help for CMD.EXE and batch files under Windows 2000! |
| Printable Version 5,548 / 12 |
| Floor1 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
Sender: kyj (kkkkkkkk), Board: DOS
Title: Help for CMD.EXE and batch files under Windows 2000! Posted at: BBS Shuimu Tsinghua Station (Fri Jan 18 16:15:35 2002) ASSOC Displays or modifies file extension associations AT Schedules commands and programs to run on a computer. ATTRIB Displays or changes file attributes. BREAK Sets or clears extended CTRL+C checking. CACLS Displays or modifies access control lists (ACLs) of files. CALL Calls one batch program from another. CD Displays the name of or changes the current directory. CHCP Displays or sets the active code page number. CHDIR Displays the name of or changes the current directory. CHKDSK Checks a disk and displays a status report. CHKNTFS Displays or modifies the checking of disk at boot time. CLS Clears the screen. CMD Starts a new instance of the Windows 2000 command interpreter. COLOR Sets the default console foreground and background colors. COMP Compares the contents of two files or sets of files. COMPACT Displays or alters the compression of files on NTFS partitions. CONVERT Converts FAT volumes to NTFS. You cannot convert the current drive. COPY Copies one or more files to another location. DATE Displays or sets the date. DEL Deletes one or more files. DIR Displays a list of files and subdirectories in a directory. DISKCOMP Compares the contents of two floppy disks. DISKCOPY Copies the contents of one floppy disk to another. DOSKEY Edits command lines, recalls Windows 2000 commands, and creates macros. ECHO Displays messages, or turns command echoing on or off. ENDLOCAL Ends localization of environment changes in a batch file. ERASE Deletes one or more files. EXIT Quits the CMD.EXE program (command interpreter). FC Compares two files or sets of files, and displays the differences between them. FIND Searches for a text string in a file or files. FINDSTR Searches for strings in files. FOR Runs a specified command for each file in a set of files. FORMAT Formats a disk for use with Windows 2000. FTYPE Displays or modifies file types used in file extension associations. GOTO Directs the Windows 2000 command interpreter to a labeled line in a batch program. GRAFTABL Enables Windows 2000 to display an extended character set in graphics mode. HELP Provides Help information for Windows 2000 commands. IF Performs conditional processing in batch programs. LABEL Creates, changes, or deletes the volume label of a disk. MD Creates a directory. MKDIR Creates a directory. MODE Configures a system device. MORE Displays output one screen at a time. MOVE Moves one or more files from one directory to another directory. PATH Displays or sets a search path for executable files. PAUSE Suspends processing of a batch file and displays a message. POPD Restores the previous value of the current directory saved by PUSHD. PRINT Prints a text file. PROMPT Changes the Windows 2000 command prompt. PUSHD Saves the current directory then changes it. RD Removes a directory. RECOVER Recovers readable information from a bad or defective disk. REM Records comments (remarks) in batch files or CONFIG.SYS. REN Renames a file or files. RENAME Renames a file or files. REPLACE Replaces files. RMDIR Removes a directory. SET Displays, sets, or removes Windows 2000 environment variables. SETLOCAL Begins localization of environment changes in a batch file. SHIFT Shifts the position of replaceable parameters in batch files. SORT Sorts input. START Starts a separate window to run a specified program or command. SUBST Associates a path with a drive letter. TIME Displays or sets the system time. TITLE Sets the window title for a CMD.EXE session. TREE Graphically displays the directory structure of a drive or path. TYPE Displays the contents of a text file. VER Displays the Windows 2000 version. VERIFY Tells Windows 2000 whether to verify that your files are written correctly to a disk. VOL Displays a disk volume label and serial number. XCOPY Copies files and directory trees. |
|
| Floor2 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
Displays or modifies file extension associations
ASSOC ]] .ext Specifies the file extension associated with the file type fileType Specifies the file type associated with the file extension Type ASSOC with no parameters to display the current file associations. If ASSOC is called with only a file extension, it displays the current file association for that file extension. If no parameters are specified for the file type, the command deletes the association for the file extension. --------------------------------------------------------------- The AT command schedules commands and programs to run at a specified date and time. To use the AT command, the Schedule service must already be running. AT | /DELETE ] AT time | /NEXT:date] "command" \\computername Specifies a remote computer. If this parameter is omitted, commands are scheduled to run on the local computer. id Specifies the identification number assigned to a scheduled command. /delete Deletes a scheduled command. If id is omitted, all scheduled commands on the computer are deleted. /yes Used with the command to delete all jobs when no further confirmation is required. time Specifies the time to run the command. /interactive Allows the job to interact with the desktop of the user who is logged on at the time it runs. /every:date Runs the command on the specified date every month or every week. If the date is omitted, the default is the current day of the month. /next:date Specifies that the command runs on the next specified date (for example, next Thursday). If the date is omitted, the default is the current day of the month. "command" The Windows NT command or batch program to run. --------------------------------------------------------------- Displays or changes file attributes. ATTRIB filename] ] ] ] filename Displays ACLs. /T Changes the ACLs of the specified files in the current directory and all subdirectories. /E Edits the ACL instead of replacing it. /C Continues on access denied errors. /G user:perm Grants the specified user access rights. Perm can be: R Read W Write C Change (write) F Full control /R user Revokes access rights for the specified user (valid only with /E). /P user:perm Replaces access rights for the specified user. Perm can be: N None R Read W Write C Change (write) F Full control /D user Denies access to the specified user. Wildcards can be used in the command to specify multiple files. Multiple users can also be specified in the command. --------------------------------------------------------------- Calls another batch program from a batch program. CALL filename batch-parameters Specifies the command-line information required by the batch program. If command extensions are enabled, CALL changes as follows: The CALL command now accepts labels as the target of CALL. The syntax is: CALL:label arguments A new batch file context is created with the specified arguments, and control is passed to the statement after the specified label. You must "exit" twice by reaching the end of the batch script file twice. The first time the end of the file is read, control returns to immediately after the CALL statement. The second time exits the batch script. Type GOTO /? to see the description of the GOTO :EOF extension, which lets you return from a batch script. In addition, batch script text argument references (%0, %1, etc.) have changed as follows: %* in a batch script indicates all arguments (such as %1 %2 %3 %4 %5 ...) Substitution of batch parameters (%n) has been enhanced. You can use the following syntax: %~1 - removes quotes (" , expanding %1%~f1 - expands %1 to a fully qualified path name %~d1 - expands %1 to a drive letter only %~p1 - expands %1 to a path only %~n1 - expands %1 to a file name only %~x1 - expands %1 to a file extension only %~s1 - expanded path contains short names %~a1 - expands %1 to file attributes %~t1 - expands %1 to the file date/time %~z1 - expands %1 to the file size %~$PATH : 1 - searches the directories listed in the PATH environment variable and expands %1 to the first fully qualified name found. If the environment variable name is not defined, or the file is not found, this combination expands to an empty string Modifiers can be combined to get compound results: %~dp1 - expands %1 only to a drive letter and path %~nx1 - expands %1 only to a file name and extension %~dp$PATH:1 - searches for %1 in the directories listed in the PATH environment variable, and expands to the drive letter and path of the first file found. %~ftza1 - expands %1 to a DIR-like output line. In the above examples, %1 and PATH can be replaced by other valid values. The %~ syntax is terminated by a valid argument number. The %~ modifiers cannot be used with %* --------------------------------------------------------------- Displays the current directory name or changes the current directory. CHDIR CHDIR CD CD .. Specifies changing to the parent directory. Type CD drive: to display the current directory on the specified drive. Type CD with no parameters to display the current drive and directory. Use the /D command option to change the current drive as well as changing the current directory for a drive. If command extensions are enabled, CHDIR changes as follows: The current directory string is converted to use the case as it appears on disk. So, if that is the case on the disk, CD C : \TEMP will set the current directory to C:\Temp. The CHDIR command does not treat spaces as delimiters, so it is possible to change to a subdirectory name that contains spaces without using quotes. For example: cd \winnt\profiles\username\programs\start menu is the same as: cd "\winnt\profiles\username\programs\start menu" When extensions are disabled, you must type the above command. |
|
| Floor3 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
---------------------------------------------------------------
Displays or sets the active code page number. CHCP nnn Specifies a code page number. Type CHCP without parameters to display the active code page number. --------------------------------------------------------------- Displays the current directory name or changes the current directory. CHDIR CHDIR CD CD .. Specifies changing to the parent directory. Type CD drive: to display the current directory on the specified drive. Type CD with no parameters to display the current drive and directory. Use the /D command option to change the current drive as well as changing the current directory for a drive. If command extensions are enabled, CHDIR changes as follows: The current directory string is converted to use the case as it appears on disk. So, if that is the case on the disk, CD C : \TEMP will set the current directory to C:\Temp. The CHDIR command does not treat spaces as delimiters, so it is possible to change to a subdirectory name that contains spaces without using quotes. For example: cd \winnt\profiles\username\programs\start menu is the same as: cd "\winnt\profiles\username\programs\start menu" When extensions are disabled, you must type the above command. --------------------------------------------------------------- Checks a disk and displays a status report. CHKDSK filename]]] ] volume Specifies the drive (followed by a colon), mount point, or volume name. filename FAT only: Specifies the file to check for fragmentation. /F Fixes errors on the disk. /V On FAT/FAT32: Displays the full path and name of every file on the disk. On NTFS: Displays cleanup messages, if any. /R Locates bad sectors and recovers readable information (implies /F). /L:size NTFS only: Changes the log file size to the specified number of KB. If no size is specified, displays the current size. /X Forces the volume to dismount first, if necessary. All open handles to the volume become invalid (implies /F). /I NTFS only: Performs a less vigorous check of index entries. /C NTFS only: Skips checking of cycles within the folder structure. The /I and /C command options skip certain checks of the volume, reducing the time required to run Chkdsk. --------------------------------------------------------------- Displays or modifies disk checking at startup. CHKNTFS volume CHKNTFS /D CHKNTFS /T\r\nCHKNTFS /X volume CHKNTFS /C volume volume: Specifies the drive (followed by a colon), mount point, or volume name. /D Restores the computer to the default state, checking all drives at startup and running the chkdsk command on drives that have problems. /T:time Changes the AUTOCHK initial countdown time to the specified amount of time, in seconds. If no time is specified, displays the current setting. /X Excludes drives from checking at startup. Drives excluded by the last execution of this command are no longer valid. /C Schedules a drive to be checked at startup; if the drive has problems, runs chkdsk. If no command option is specified, CHKNTFS displays the status of the dirty bit for each drive. --------------------------------------------------------------- Clears the screen. CLS --------------------------------------------------------------- Starts a new instance of the Windows 2000 command interpreter CMD string] /C Executes the command specified by the string and then terminates /K Executes the command specified by the string but remains /S Modifies string handling after /C or /K (see below) /Q Turns echo off /D Disables execution of AutoRun commands from the registry (see below) /A Causes output to internal pipes or file commands to be ANSI /U Causes output to internal pipes or file commands to be Unicode /T:fg Sets foreground/background colors (for details, see COLOR /?) /E:ON Enables command extensions (see below) /E:OFF Disables command extensions (see below) /F:ON Enables file and directory name completion characters (see below) /F:OFF Disables file and directory name completion characters (see below) /V:ON Starts delayed environment variable expansion using c as the delimiter. For example: /V:ON allows !var! to expand the variable var at execution time. The var syntax expands variables at input time, which is different inside a FOR loop. /V:OFF Disables delayed environment expansion. Note that if the string is quoted, multiple commands separated by the command separator '&&' are accepted. Also, for compatibility reasons, /X is the same as /E:ON, /Y is the same as /E:OFF, and /R is the same as /C. Any other command options are ignored. If /C or /K is specified, the rest of the command line after the command options is processed as a command line; in this case, the following logic is used to process quote characters (" :1. If all of the following conditions are met, quote characters on the command line are preserved: - No /S command option - Exactly two quote characters - No special characters between the two quote characters, the special characters being one of the following: ()@^| - At least one whitespace character between the two quote characters - At least one executable file name between the two quote characters. 2. Otherwise, the old method is used: if the first character is a quote character, discard the leading character and delete the last quote character on the command line, preserving any text after the last quote character. If /D is not specified on the command line, when CMD.EXE starts it looks for the following REG_SZ/REG_EXPAND_SZ registry variables. If either or both exist, they are executed first. HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun Command extensions are enabled by default. You can also use /E:OFF to disable extensions for a particular invocation. You can enable or disable extensions for all invocations of CMD.EXE on the machine and/or user logon session by setting one or both of the following REG_DWORD values in the registry using REGEDT32.EXE: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions to 0x1 or 0x0. User-specific settings take precedence over machine settings. Command-line command options take precedence over registry settings. Command-line extensions include changes and/or additions to the following commands: DEL or ERASE COLOR CD or CHDIR MD or MKDIR PROMPT PUSHD POPD SET SETLOCAL ENDLOCAL IF FOR CALL SHIFT GOTO START (also including changes made to external command invocation) ASSOC FTYPE For details, type HELP command-name. Delayed variable environment expansion is not enabled by default. You can use the /V:ON or /V:OFF command options to enable or disable delayed environment variable expansion for a particular invocation of CMD.EXE. You can enable or disable completion for all invocations of CMD.EXE on the machine and/or user logon session by setting one or both of the following REG_DWORD values in the registry using REGEDT32.EXE: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion to 0x1 or 0x0. User-specific settings take precedence over machine settings. Command-line command options take precedence over registry settings. If delayed environment variable expansion is enabled, the exclamation point character can be used at execution time to substitute the value of an environment variable. File and directory name completion is not enabled by default. You can use the /F:ON or /F:OFF command options to enable or disable file name completion for a particular invocation of CMD.EXE. You can enable or disable completion for all invocations of CMD.EXE on the machine and/or user logon session by setting one or both of the following REG_DWORD values in the registry using REGEDT32.EXE: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar using the hexadecimal value of a control character as a specific parameter (for example, 0x4 is Ctrl-D, 0x6 is Ctrl-F). User-specific settings take precedence over machine settings. Command-line command options take precedence over registry settings. If completion is enabled with the /F:ON command option, the two control characters to use are: Ctrl-D for directory name completion and Ctrl-F for file name completion. To disable a character in the registry, use the value for space (0x20), because this character is not a control character. If you type one of the two control characters, completion is invoked. The completion function takes the path string to the left of the cursor, appends a wildcard to the left if there is no wildcard, and builds a list of matching paths. It then displays the first matching path. If there is no matching path, it beeps and does not affect the display. After that, pressing the same control character repeatedly cycles through the list of matching paths. Pressing Shift together with the control character displays the list in reverse. If any editing is done to the line and the control character is pressed again, the saved list of matching paths is discarded and a new one is generated. The same occurs if switching between file and directory name completion. The only difference between the two control characters is that the file completion character matches file and directory names, while the directory completion character only matches directory names. If file completion is used with built-in directory commands (CD, MD or RD), directory completion is used. By putting quotes around matching paths, the completion code can correctly handle file names containing spaces or other special characters. Also, if you back up and then invoke file completion from within the line, text to the right of the cursor when completion is invoked will be discarded. --------------------------------------------------------------- Sets the default console foreground and background colors. COLOR attr Specifies the color attribute of console output Color attributes are specified by two hexadecimal digits -- the first is the background, and the second is the foreground. Each digit can be any of the following values: 0 = black 8 = gray 1 = blue 9 = light blue 2 = green A = light green 3 = aqua B = light aqua 4 = red C = light red 5 = purple D = light purple 6 = yellow E = light yellow 7 = white F = bright white If no argument is given, the command restores the colors to those at CMD.EXE startup. This value comes from the current console window, the /T command-line option, or the DefaultColor registry value. If the COLOR command is executed with the same foreground and background color, the COLOR command sets ERRORLEVEL to 1. For example: "COLOR fc" produces bright red on bright white --------------------------------------------------------------- Compares the contents of two files or sets of files. COMP data1 Specifies the location and name of the first file(s) to compare. data2 Specifies the location and name of the second file(s) to compare. /D Displays differences in numeric format. /A Displays differences in ASCII characters.. /L Displays line number differences. /N=number Compares only the first specified number of lines of each file. /C Ignores the case of ASCII characters when comparing files. To compare sets of files, use wildcards in the data1 and data2 parameters. --------------------------------------------------------------- Displays or changes the compression of files on NTFS partitions. COMPACT ] ] /C Compresses the specified files. Directories are marked so that files added later will be compressed. /U Uncompresses the specified files. Directories are marked so that files added later will not be compressed. /S Performs the specified operation on files in the specified directory and all subdirectories. The default "dir" is the current directory. /A Displays files with hidden or system attributes. By default, these files are ignored. /I Continues performing the specified operation even after errors occur. By default, COMPACT stops when it encounters an error. /F On all-------------------------------------------------------------- Converts a FAT volume to NTFS. CONVERT volume /FS:NTFS volume Specifies the drive (followed by a colon), mount point, or volume name. /FS:NTFS Specifies that the volume is to be converted to NTFS. /V Specifies that conversion must be performed in verbose mode. --------------------------------------------------------------- Copies one or more files to another location. COPY source ] ] source Specifies the file to copy. /A Indicates an ASCII text file. /B Indicates a binary file. destination Specifies the directory and/or file name for the new file. /V Verifies that new files are written correctly. /N When copying a file with a non-8dot3 name, uses the short file name if possible. /Y Suppresses prompting to confirm that you want to overwrite an existing destination file. /-Y Causes prompting to confirm that you want to overwrite an existing destination file. /Z Copies networked files in restartable mode. The /Y command option can be preset in the COPYCMD environment variable. This can be overridden by /-Y on the command line. Unless the COPY command is executed in a batch file script, the default should be to prompt when overwriting. To append files, specify one file as the destination and several files as the source (using wildcards or the file1+file2+file3 format). --------------------------------------------------------------- Displays or sets the date. DATE Type DATE without parameters to display the current date setting and prompt you to enter a new date. Press ENTER to keep the original date. If command extensions are enabled, the DATE command supports the /T command option; this option tells the command to output only the current date without prompting for a new date. --------------------------------------------------------------- Deletes one or more files. DEL attributes]] names ERASE attributes]] names names Specifies a list of one or more files or directories. Wildcards can be used to delete multiple files. If a directory is specified, all files in the directory are deleted. /P Prompts for confirmation before deleting each file. /F Forces deletion of read-only files. /S Deletes specified files from all subdirectories. /Q Quiet mode. Does not ask for confirmation when deleting with global wildcards. /A Selects files to delete based on attributes. attributes R Read-only files S System files H Hidden files A Archive files - Prefix meaning "not" If command extensions are enabled, DEL and ERASE change as follows: The display syntax of the /S command option is reversed, that is, it shows you only files that have been deleted, and does not show files that could not be found. --------------------------------------------------------------- Displays a list of files and subdirectories in a directory. DIR attributes]] sortorder]] timefield]] Specifies the drive, directory and/or files to list. /A Displays files with the specified attributes. attributes D Directories R Read-only files H Hidden files A Files ready for archiving S System files - Prefix meaning "not" /B Uses bare format (no heading information or summary). /C Displays thousands separators in file sizes. This is the default. Use /-C to disable separator display. /D Same as wide format, but files are listed sorted by column. /L Uses lowercase. /N New long list format, with file names at the far right. /O Lists files in sorted order. sortorder N By name (alphabetical) S By size (smallest first) E By extension (alphabetical) D By date/time (oldest first) G Group directories first - Prefix to reverse order /P Pauses after each screen of information. /Q Displays file owner. /S Displays files in the specified directory and all subdirectories. /T Controls which time field is displayed or used for sorting. timefield C Creation time A Last access time W Last write time /W Uses wide list format. /X Displays the short names generated for non-8dot3 file names. The format is /N format, with the short name inserted before the long name. If there is no short name, blanks are displayed in its place. /4 Displays the year with four digits Command options can be preset in the DIRCMD environment variable. Override preset command options by prefixing with - (hyphen), for example, /-W. --------------------------------------------------------------- |
|
| Floor4 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
Compares the contents of two floppy disks.
DISKCOMP ] --------------------------------------------------------------- Copies the contents of one floppy disk to another. DISKCOPY ] /V Verifies that the information was copied correctly. The two floppy disks must be of the same type. You can specify the same drive for drive1 and drive2. --------------------------------------------------------------- Edits command lines, recalls Windows 2000 commands, and creates macros. DOSKEY ] ] /REINSTALL Installs a new set of Doskey. /LISTSIZE=size Sets the command history buffer size. /MACROS Displays all Doskey macros. /MACROS:ALL Displays all Doskey macros for executables that have Doskey macros. /MACROS:exename Displays all Doskey macros for the specified executable. /HISTORY Displays all commands saved in memory. /INSERT Specifies that new text typed is inserted into old text. /OVERSTRIKE Specifies that new text overwrites old text. /EXENAME=exename Specifies the executable. /MACROFILE=filename Specifies the macro file to install. macroname Specifies the name of the macro to create. text Specifies the command to be registered. Use the up and down arrow keys to select commands; ESC clears the command line; F7 displays the command history; ALT+F7 clears the command history; F8 searches the command history; F9 selects a command by number; ALT+F10 clears macro definitions. The following are special codes for Doskey macro definitions: $T Command separator. Allows a macro to contain multiple commands. $1-$9 Batch parameters. Same as %1-%9 in batch programs. $* Symbol replaced by anything after the command name on the command line. --------------------------------------------------------------- Displays messages, or turns command echoing on or off. ECHO ECHO Type ECHO without parameters to display the current ECHO setting. --------------------------------------------------------------- Ends localization of environment changes in a batch file. Environment changes made after executing ENDLOCAL are no longer limited to the batch file. After the batch file ends, the original settings cannot be restored. ENDLOCAL If command extensions are enabled, ENDLOCAL changes as follows: If the corresponding SETLOCAL enabled or disabled command extensions with the new ENABLEEXTENSIONS or DISABLEEXTENSIONS options, then after ENDLOCAL, the enabled/disabled state of command extensions is restored to the state before the corresponding SETLOCAL command was executed. --------------------------------------------------------------- Deletes one or more files. DEL attributes]] names ERASE attributes]] names names Specifies a list of one or more files or directories. Wildcards can be used to delete multiple files. If a directory is specified, all files in the directory are deleted. /P Prompts for confirmation before deleting each file. /F Forces deletion of read-only files. /S Deletes specified files from all subdirectories. /Q Quiet mode. Does not ask for confirmation when deleting with global wildcards. /A Selects files to delete based on attributes. attributes R Read-only files S System files H Hidden files A Archive files - Prefix meaning "not" If command extensions are enabled, DEL and ERASE change as follows: The display syntax of the /S command option is reversed, that is, it shows you only files that have been deleted, and does not show files that could not be found. --------------------------------------------------------------- Exits the CMD.EXE program (command interpreter) or the current batch file script. EXIT /B Specifies exiting the current batch script instead of CMD.EXE. If executed outside a batch script, CMD.EXE will be exited exitCode Specifies a numeric number. If /B is specified, sets ERRORLEVEL to that number. If exiting CMD.EXE, sets the process exit code to that number. --------------------------------------------------------------- Compares two files or two sets of files, and displays the differences between them FC filename1 filename2 FC /B filename1 filename2 /A Displays only the first and last line of each set of differences. /B Performs a binary comparison. /C Ignores case. /L Compares files as ASCII text. /LBn Sets the maximum number of consecutive mismatches to the specified number of lines. /N Displays line numbers in an ASCII comparison. /T Does not expand tabs to spaces. /U Compares files as UNICODE text files. /W Compresses whitespace (tabs and spaces) for comparison. /nnnn Specifies the number of consecutive lines that must match after a mismatch. --------------------------------------------------------------- Searches for a string in files. FIND "string" filename] /V Displays all lines that do not contain the specified string. /C Displays only the count of lines containing the string. /N Displays line numbers. /I Ignores case when searching for the string. "string" Specifies the text string to search for, filename Specifies the file to search. If no path is specified, FIND searches the typed text or the text generated by another command. --------------------------------------------------------------- Searches for strings in files. FINDSTR filename] /B Matches pattern at the beginning of a line. /E Matches pattern at the end of a line. /L Uses search strings literally. /R Uses search strings as regular expressions. /S Searches matching files in the current directory and all subdirectories. /I Specifies that the search is not case-sensitive. /X Prints lines that match exactly. /V Prints only lines that do not contain a match. /N Prints the line number before each matching line. /M Prints only the file name if the file contains a match. /O Prints the character offset before each matching line. /P Skips files with non-printable characters. /A:attr Specifies color attributes with hexadecimal digits. See "color /?" /F:file Reads a file list from the specified file (/ means console). /C:string Uses the specified string as a literal search string. /G:file Gets search strings from the specified file. (/ means console). /D:dir Searches a semicolon-delimited list of directories strings The text to search for. filename Specifies the file to search. Unless an argument has the /C prefix, use spaces to separate search strings. For example: 'FINDSTR "hello there" x.y' searches for "hello" or "there" in file x.y. 'FINDSTR /C:"hello there" x.y' searches file x.y for "hello there". Quick reference for regular expressions: . Wildcard: any character * Repeat: previous character or class occurs zero or more times ^ Line position: beginning of line $ Line position: end of line Character class: any character in the set Complement character class: any character not in the set Range: any character in the specified range \x Escape: literal use of metacharacter x \ Word position: end of word For details on common FINDSTR expressions, see the online command reference. --------------------------------------------------------------- Runs a specified command for each file in a set of files. FOR %variable IN (set) DO command %variable Specifies a replaceable parameter. (set) Specifies one or more files. Wildcards can be used. command Specifies the command to execute for each file. command-parameters Specifies parameters for the particular command. When using the FOR command in a batch file, use %%variable to specify the variable instead of %variable. Variable names are case-sensitive, so %i is different from %I. If command extensions are enabled, the following additional FOR command formats are supported: FOR /D %variable IN (set) DO command If the set contains wildcards, specifies matching directory names rather than file names. FOR /R path] %variable IN (set) DO command Checks the directory tree rooted at path, pointing to the FOR statement in each directory. If no directory is specified after /R, the current directory is used. If the set is only a single dot (.) character, the directory tree is enumerated. FOR /L %variable IN (start,step,end) DO command The set represents a sequence of numbers from start to end in increments. Thus, (1,1,5) produces the sequence 1 2 3 4 5, and (5,-1,1) produces the sequence (5 4 3 2 1). FOR /F %variable IN (file-set) DO command FOR /F %variable IN ("string" DO command FOR /F %variable IN ('command' DO command Or, if the usebackq option is present: FOR /F %variable IN (file-set) DO command FOR /F %variable IN ("string" DO command FOR /F %variable IN ('command' DO command filenameset is one or more file names. Before continuing to the next file in filenameset, each file is opened, read, and processed. Processing consists of reading the file, splitting it into lines of text, and then parsing each line into zero or more tokens. The For loop is then called with variable values set to the token strings found. By default, /F separates on the first blank token in each line of each file. Blank lines are skipped. You can override the default parsing operation by specifying the optional "options" parameter. This quoted string contains one or more keywords specifying different parsing options. These keywords are: eol=c - specifies an end-of-line comment character (just one) skip=n - specifies the number of lines to ignore at the beginning of the file. delims=xxx - specifies a delimiter set. This replaces the default delimiter set of space and tab. tokens=x,y,m-n - specifies which tokens from each line are passed to the for body for each iteration. This causes additional variable names to be allocated. The m-n format is a range. It specifies the mth through nth tokens. If the last character in the token string is an asterisk, then an additional variable is allocated after the last token parsed and receives the remaining text of the line. usebackq - specifies that new syntax is used in the following cases: executing a back-quoted string as a command, and a single-quoted character as a literal string command, and allows file names in filenameset to be enclosed in double quotes. Some examples may help: FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k parses each line in myfile.txt, ignoring those lines beginning with semicolons, and passes the second and third tokens from each line to the for body, using comma and/or space as token delimiters. Note that the statements in this for body reference %i to get the second token, %j to get the third token, and %k to get all remaining tokens after the third token. For file names with spaces, you need to enclose the file name in double quotes. To use double quotes in this way, you also need to use the usebackq option; otherwise, the double quotes will be understood as defining a string to be parsed. %i is explicitly declared in the for statement, and %j and %k are explicitly declared through the tokens= option. You can specify up to 26 tokens via one tokens= line, as long as you do not try to declare a variable higher than the letter 'z' or 'Z'. Remember, FOR variable names are case-sensitive and global; also, no more than 52 can be in use at the same time. You can also use the FOR /F parsing logic on an adjacent string; the method is to enclose the filenameset between the parentheses in single quotes. That string is then treated as a single input line in a file. Finally, you can use the FOR /F command to parse the output of a command. The method is to make the filenameset between the parentheses a back-quoted string. That string is treated as a command line, passed to a child CMD.EXE, whose output is captured into memory and parsed as a file. Thus the following example: FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i enumerates the environment variable names in the current environment. In addition, substitution of FOR variable references has been enhanced. You can now use the following option syntax: ~I - removes any quotes (" , expanding %I%~fI - expands %I to a fully qualified path name %~dI - expands %I to a drive letter only %~pI - expands %I to a path only %~nI - expands %I to a file name only %~xI - expands %I to a file extension only %~sI - expanded path contains short names only %~aI - expands %I to the file's file attributes %~tI - expands %I to the file date/time %~zI - expands %I to the file size %~$PATH:I - searches the directories listed in the PATH environment variable and expands %I to the first fully qualified name found. If the environment variable name is not defined, or the file is not found, this combination expands to an empty string Modifiers can be combined to get compound results: %~dpI - expands %I only to a drive letter and path %~nxI - expands %I only to a file name and extension %~fsI - expands %I only to a full path name with short names %~dp$PATH:i - searches the directories listed in the PATH environment variable and expands %I to the drive letter and path of the first found file. %~ftzaI - expands %I to a DIR-like output line In the above examples, %I and PATH can be replaced by other valid values. The %~ syntax is terminated by a valid FOR variable name. Choosing uppercase variable names like %I is more readable and avoids confusion with case-insensitive combinations. |
|
| Floor5 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
---------------------------------------------------------------
Formats a disk for use with Windows 2000. FORMAT volume FORMAT volume FORMAT volume FORMAT volume FORMAT volume volume Specifies the drive (followed by a colon), mount point, or volume name. /FS:filesystem Specifies the file system type (FAT, FAT32 or NTFS). /V:label Specifies the volume label. /Q Performs a quick format. /C By default, files created on the newly created volume will be compressed. /X Forces the volume to dismount first, if necessary. At that time, all open handles to the volume are no longer valid. /A:size Overrides the default allocation unit size. It is strongly recommended that you use the default setting in normal situations. NTFS supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K. FAT supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64k, (128k, 256k for sectors larger than 512 bytes). FAT32 supports 512, 1024, 2048, 4096, 8192, 16k, 32k, 64k, (128k, 256k for sectors larger than 512 bytes). Note that FAT and FAT32 file systems have the following limitations on the number of clusters on a volume: FAT: number of clusters <= 65526 FAT32: 65526 < number of clusters < 268435446 If it is determined that the above requirements cannot be met using the specified cluster size, formatting will stop immediately. NTFS compression does not support allocation units larger than 4096. /F:size Specifies the size of the floppy disk to format (160, 180, 320, 360, 640, 720, 1.2, 1.23, 1.44, 2.88, or 20.8). /T:tracks Specifies the number of tracks per side of the disk. /N:sectors Specifies the number of sectors per track. /1 Formats a single-sided floppy disk. /4 Formats a 5.25-inch 360K floppy disk in a high-density drive. /8 Formats eight sectors per track. --------------------------------------------------------------- Displays or modifies file types used in file extension associations FTYPE ]] fileType Specifies the file type to examine or change openCommandString Specifies the open command to use when invoking this type of file. Type FTYPE without parameters to display the file types currently defined with open command strings. When FTYPE is enabled with only one file type, it displays the current open command string for that file type. If no open command string is specified, the FTYPE command deletes the open command string for that file type. Within an open command string, the command strings %0 or %1 are replaced by the file name invoked through the association. %* gets all parameters, %2 gets the first parameter, %3 gets the second, and so on. %~n gets all remaining parameters beginning with the nth parameter; n can be a number from 2 to 9. For example: ASSOC .pl=PerlScript FTYPE PerlScript=perl.exe %1 %* allows you to enable the following Perl script: script.pl 1 2 3 If you do not want to type the extension, type the following string: set PATHEXT=.pl;%PATHEXT% The script started is as follows: script 1 2 3 --------------------------------------------------------------- Directs cmd.exe to a labeled line in a batch program. GOTO label label Specifies the text string used as the label in the batch program. The label must be on a line by itself and begin with a colon. If command extensions are enabled, GOTO changes as follows: The GOTO command now accepts the target label :EOF, which transfers control to the end of the current batch script file. This is an easy way to exit a batch script file without defining anything. Type CALL /? for a description of the CALL command extensions that make this feature useful. --------------------------------------------------------------- Please enable Windows to display an extended character set in graphics mode. GRAFTABL GRAFTABL /STATUS xxx Specifies the code page. /STATUS Displays the current code page selected for use with GRAFTABL. --------------------------------------------------------------- Provides help information for Windows 2000 commands. HELP command - Displays help information for that command. --------------------------------------------------------------- Performs conditional processing in batch programs. IF ERRORLEVEL number command IF string1==string2 command IF EXIST filename command NOT Specifies that Windows 2000 should execute the command only if the condition is false. ERRORLEVEL number Specifies a true condition if the last program run returned an exit code equal to or greater than the specified number. string1==string2 Specifies a true condition if the specified text strings match. EXIST filename Specifies a true condition if the specified file name exists. command Specifies the command to execute if the condition is met. If the specified condition is FALSE, an ELSE command can follow the command, and the ELSE command will execute the command after the ELSE keyword. The ELSE clause must appear on the same line after IF. For example: IF EXIST filename. ( del filename. ) ELSE ( echo filename. missing. ) Because the del command must be terminated with a new line, the following clause will not work: IF EXIST filename. del filename. ELSE echo filename. missing Since the ELSE command must be on the same line as the end of the IF command, the following clause will also not work: IF EXIST filename. del filename. ELSE echo filename. missing If all placed on one line, the following clause works: IF EXIST filename. (del filename.) ELSE echo filename. missing If command extensions are enabled, IF changes as follows: IF string1 compare-op string2 command IF CMDEXTVERSION number command IF DEFINED variable command where the comparison operators can be: EQU - equal NEQ - not equal LSS - less than LEQ - less than or equal GTR - greater than GEQ - greater than or equal and the /I command option; if this command option is specified, it means that string comparisons are not case-sensitive. The /I command option can be used with the string1==string2 form of IF. These comparisons are general; if string1 and string2 are both composed of digits, the strings are converted to numbers and a numeric comparison is performed. The CMDEXTVERSION condition works the same as ERRORLEVEL, except that it compares against the internal version number associated with command extensions. The first version is 1. Each time command extensions have a substantial enhancement, the version number is increased by one. When command extensions are disabled, the CMDEXTVERSION condition is not true. If the environment variable is defined, the DEFINED condition works the same as EXISTS, except that it takes an environment variable and returns true. If there is no environment variable named ERRORLEVEL, %ERRORLEVEL% expands to a string expression of the current ERROLEVEL value; otherwise, you get its value. After running a program, the following statements illustrate the use of ERRORLEVEL: goto answer%ERRORLEVEL% :answer0 echo Program had return code 0 :answer1 echo Program had return code 1 You can also use the above numeric comparisons: IF %ERRORLEVEL% LEQ 1 goto okay If there is no environment variable named CMDCMDLINE, %CMDCMDLINE% expands to the original command line passed to CMD.EXE before CMD.EXE performs any processing; otherwise, you get its value. If there is no environment variable named CMDEXTVERSION, %CMDEXTVERSION% expands to a string expression of the current CMDEXTVERSION value; otherwise, you get its value. |
|
| Floor6 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
---------------------------------------------------------------
Creates, changes, or deletes a disk volume label. LABEL LABEL drive: Specifies the drive name. label Specifies the volume label. /MP Specifies that the volume should be treated as a mount point or volume name. volume Specifies the drive (followed by a colon), mount point, or volume name. If a volume name is specified, the /MP flag is not necessary. --------------------------------------------------------------- Creates a directory. MKDIR path MD path If command extensions are enabled, MKDIR changes as follows: MKDIR creates intermediate directories in the path if needed. For example: Suppose \a does not exist, then: mkdir \a\b\c\d is the same as: mkdir \a chdir \a mkdir b chdir b mkdir c chdir c mkdir d If extensions are disabled, you need to type mkdir \a\b\c\d. --------------------------------------------------------------- Creates a directory. MKDIR path MD path If command extensions are enabled, MKDIR changes as follows: MKDIR creates intermediate directories in the path if needed. For example: Suppose \a does not exist, then: mkdir \a\b\c\d is the same as: mkdir \a chdir \a mkdir b chdir b mkdir c chdir c mkdir d If extensions are disabled, you need to type mkdir \a\b\c\d. --------------------------------------------------------------- Configures system devices. Serial port: MODE COMm Device status: MODE Print redirection: MODE LPTn=COMm Select code page: MODE CON CP SELECT=yyy Code page status: MODE CON CP Display mode: MODE CON Keystroke rate: MODE CON --------------------------------------------------------------- Displays output one screen at a time. MORE ] < filename command-name | MORE ] MORE /E filename Specifies the file to display one screen at a time. command-name Specifies the command whose output is to be displayed. /E Enables extended features /C Clears the screen before displaying a page /P Expands FormFeed characters /S Squeezes multiple blank lines into one line /Tn Expands tabs to n spaces (default is 8) Command options can appear in the MORE environment variable. +n Starts displaying the first file from line n files List of files to display. Separate files in the list with spaces. If extended features are enabled, the following commands are accepted at the -- More -- prompt: P n Displays the next n lines S n Skips the next n lines F Displays the next file Q Quits = Displays the line number ? Displays the help line Displays the next page Displays the next line --------------------------------------------------------------- Moves files and renames files and directories. To move at least one file: MOVE filename1 destination To rename a directory: MOVE dirname1 dirname2 filename1 Specifies the location and name of the file you want to move. destination Specifies the new location of the file. The destination can include a drive letter and colon, a directory name, or a combination. If moving only one file and renaming it while moving, you can also include a file name. dirname1 Specifies the directory to rename. dirname2 Specifies the new name of the directory. /Y Suppresses prompting to confirm overwriting an existing destination file. /-Y Prompts to confirm overwriting an existing destination file. The /Y command option can appear in the COPYCMD environment variable. This can be overridden with /-Y on the command line. The default is to prompt on overwrite unless the MOVE command is executed from within a batch script. |
|
| Floor7 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
---------------------------------------------------------------
Displays or sets a search path for executable files. PATH path PATH ; Type PATH ; to clear all search path settings and instruct cmd.exe to search only in the current directory. Type PATH without parameters to display the current path. Including %PATH% in the new path setting appends the old path to the new setting. --------------------------------------------------------------- Pauses processing of a batch program and displays the following message: Press any key to continue . . . ------------------------------------------------------- Command option to the directory saved by the PUSHD command. POPD If command extensions are enabled, when POPD pops a drive from the pushd directory stack, the POPD command deletes the temporary drive letter created by PUSHD. --------------------------------------------------------------- Prints a text file. PRINT filename] /D:device Specifies the printer device. --------------------------------------------------------------- Changes the cmd.exe command prompt. PROMPT text Specifies the new command prompt. The prompt can consist of normal characters and the following special codes: $A & (Ampersand) $B | (pipe) $C ( (left parenthesis) $D Current date $E Escape code (ASCII code 27) $F ) (right parenthesis) $G > (greater-than sign) $H Backspace (erases previous character) $L < (less-than sign) $N Current drive $P Current drive and path $Q = (equals sign) $S (space) $T Current time $V Windows 2000 version number $_ New line $$ $ (currency symbol) If command extensions are enabled, the PROMPT command supports the following formatting characters: $+ Zero or more plus sign (+) characters according to the depth of the PUSHD directory stack; one character for each pushed level. $M Displays the remote name associated with the current drive letter, or an empty string if the current drive is not a network drive. --------------------------------------------------------------- Saves the current directory for use by the POPD command, then changes to the specified directory. PUSHD path Specifies the directory to become the current directory. If command extensions are enabled, the PUSHD command accepts network paths in addition to ordinary drive letters and paths. If a network path is specified, PUSHD creates a temporary drive letter pointing to the specified network resource, and then changes the current drive and directory using the newly defined drive letter. Temporary drive letters can be assigned downward from Z:, using the first unused drive letter found. --------------------------------------------------------------- Removes a directory. RMDIR path RD path /S Removes all subdirectories and files under the specified directory in addition to the directory itself. Used to remove a directory tree. /Q Quiet mode; with /S, does not ask for confirmation when removing a directory tree --------------------------------------------------------------- Recovers readable information from a damaged disk. RECOVER filename Before using the RECOVER command, consult the online command reference in Windows 2000 Help. --------------------------------------------------------------- Adds comments or remarks in batch files or CONFIG.SYS. REM --------------------------------------------------------------- Renames files. RENAME filename1 filename2. REN filename1 filename2. Note that you cannot specify a new drive or path for the destination file. --------------------------------------------------------------- Renames files. RENAME filename1 filename2. REN filename1 filename2. Note that you cannot specify a new drive or path for the destination file. --------------------------------------------------------------- Replaces files. REPLACE filename REPLACE filename filename Specifies the source file. Specifies the directory where files are to be replaced. /A Adds new files to the destination directory. Cannot be used together with the /S or /U command options. /P Prompts you for confirmation before replacing files or adding source files. /R Replaces read-only files as well as unprotected files. /S Replaces files in all subdirectories of the destination directory. Cannot be used together with the /A command option. /W Waits for you to insert a disk before running. /U Replaces or updates only files older than the source file. Cannot be used together with the /A command option. --------------------------------------------------------------- Removes a directory. RMDIR path RD path /S Removes all subdirectories and files under the specified directory in addition to the directory itself. Used to remove a directory tree. /Q Quiet mode; with /S, does not ask for confirmation when removing a directory tree |
|
| Floor8 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
---------------------------------------------------------------
Displays, sets, or removes cmd.exe environment variables. SET ] variable Specifies the environment variable name. string Specifies a series of characters to assign to the variable. Type SET without parameters to display the current environment variables. If command extensions are enabled, SET changes as follows: The SET command can be activated with only one variable, without an equals sign or value, to display the values of all variables whose names match the prefix used by the SET command. For example: SET P displays all variables beginning with the letter P If the variable name cannot be found in the current environment, the SET command sets ERRORLEVEL to 1. The SET command does not allow variable names to contain an equals sign. Two new substitutions have been added to the SET command: SET /A expression SET /P variable= The /A command option specifies that the string to the right of the equals sign is a numeric expression to be evaluated. The expression evaluator is simple and supports the following operations in decreasing order of precedence: () - grouping * / % - arithmetic operators + - - arithmetic operators <> - logical shift - bitwise “and” ^ - bitwise “xor” | - bitwise “or” = *= /= %= += -= - assignment &= ^= |= <>= , - expression separator If you use any logical or remainder operators, you need to enclose the expression string in quotes. Any non-numeric string key in the expression is treated as an environment variable name, and the values of these environment variable names are converted to numbers before use. If an environment variable name is specified but is not defined in the current environment, the value is set to zero. This lets you use environment variable values in calculations without typing those % signs to get their values. If SET /A is executed on the command line outside a command script, it displays the final value of the expression. The assignment operator requires an environment variable name to the left of the assignment operator. Except for hexadecimal values with a 0x prefix and octal values with a 0 prefix, numeric values are decimal digits. Therefore, 0x12 is the same as 18 and 022. Note that octal notation can easily be confusing: 08 and 09 are invalid numbers because 8 and 9 are not valid octal digits. The /P command option allows the variable value to be set to a line of input entered by the user. Before reading the input line, the specified promptString is displayed. promptString can be empty. Environment variable substitution has been enhanced as follows: %PATH:str1=str2% expands the PATH environment variable, replacing each "str1" in the expanded result with "str2". To effectively delete all "str1" from the expanded result, "str2" can be empty. "str1" can begin with an asterisk; in that case, "str1" will match from the beginning of the expanded result up to the first occurrence of the remaining part of str1. Substrings can also be specified for expansion. %PATH:~10,5% expands the PATH environment variable, then uses only the five characters starting from the 11th character (offset 10) in the expanded result. If no length is specified, the default is the remainder of the variable value. If both numbers (offset and length) are negative, the number used is the length of the environment variable value plus the specified offset or length. %PATH:~-10% extracts the last ten characters of the PATH variable. %PATH:~0,-2% extracts all characters of the PATH variable except the last two. Support for delayed environment variable expansion has finally been added. This support is always disabled by default, but can be enabled/disabled through the /V command-line option of CMD.EXE. See CMD /? Delayed environment variable expansion is useful when considering the current limitations of expansion encountered when a line of text is read, rather than when it is executed. The following example illustrates the problem with immediate variable expansion: set VAR=before if "%VAR%" == "before" ( set VAR=after; if "%VAR%" == "after" @echo If you see this, it worked ) will not display the message, because when the first IF statement is read, %VAR% in BOTH IF statements is replaced; the reason is that it contains the body of IF, and IF is a compound statement. So the IF in the compound statement is actually comparing "before" and "after", which will never be equal. Similarly, the following example will not have the expected effect: set LIST= for %i in (*) do set LIST=%LIST% %i echo %LIST% The reason is that it does not build a list of files in the current directory, but merely sets the LIST variable to the last file found. This is also because %LIST% is expanded only once when the FOR statement is read; and at that time the LIST variable is empty. Therefore, the FOR loop we actually execute is: for %i in (*) do set LIST= %i This loop continues to set LIST to the last file found. Delayed environment variable expansion lets you use a different character (exclamation point) to expand environment variables at execution time. If delayed variable expansion is enabled, the above examples can be written as follows to achieve the expected effect: set VAR=before if "%VAR%" == "before" ( set VAR=after if "!VAR!" == "after" @echo If you see this, it worked ) set LIST= for %i in (*) do set LIST=!LIST! %i echo %LIST% If command extensions are enabled, several dynamic environment variables can be expanded but will not appear in the list of variables displayed by SET. Each time a variable value is expanded, these variable values are dynamically computed. If the user defines a variable with any of these names, that definition overrides the dynamic definition described below: %CD% - expands to the current directory string. %DATE% - expands to the current date in the same format as the DATE command. %TIME% - expands to the current time in the same format as the TIME command. %RANDOM% - expands to an arbitrary decimal number between 0 and 32767. %ERRORLEVEL% - expands to the current ERRORLEVEL value. %CMDEXTVERSION% - expands to the current command processor extension version number. %CMDCMDLINE% - expands to the original command line that invoked the command processor. |
|
| Floor9 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
--------------------------------------------------------------
Begins localization of environment changes in a batch file. Environment changes made after executing SETLOCAL are limited to the batch file. To restore the original settings, ENDLOCAL must be executed. When the end of the batch file is reached, an implicit ENDLOCAL is executed for each SETLOCAL command in that batch file that has not yet been executed. SETLOCAL If command extensions are enabled, SETLOCAL changes as follows: The SETLOCAL batch command can now accept optional parameters: ENABLEEXTENSIONS / DISABLEEXTENSIONS Enables or disables command processor extensions. For details, see CMD /?. ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION Enables or disables delayed environment variable expansion. For details, see SET /? . Regardless of what their settings were before the SETLOCAL command, these changes remain in effect until the matching ENDLOCAL command. If there is one parameter, the SETLOCAL command sets the value of ERRORLEVEL. If one of the two valid parameters is present, the value is zero. With the following trick, you can use this in a batch script to determine whether extensions are available: VERIFY OTHER 2>nul SETLOCAL ENABLEEXTENSIONS IF ERRORLEVEL 1 echo Unable to enable extensions This method works because in older versions of CMD.EXE, SETLOCAL does not set the ERRORLEVEL value. The VERIFY command with an incorrect parameter initializes the ERRORLEVEL value to a nonzero value. --------------------------------------------------------------- Changes the position of replaceable parameters in a batch file. SHIFT If command extensions are enabled, the SHIFT command supports the /n command option; this command option tells the command to start shifting at the nth parameter, where n is between zero and eight. For example: SHIFT /2 shifts %3 to %2, %4 to %3, and so on; and does not affect %0 and %1. --------------------------------------------------------------- SORT filename1] ] filename3] /+n Specifies the character number n at which each comparison starts. /+3 indicates each comparison should start at the third character of each line. Lines with fewer than n characters sort before other lines. By default, comparison starts with the first character of each line. /L locale Overrides the system default locale with the specified locale. The ""C"" locale produces the fastest sort order and is currently the only other choice. Sorting is always case-insensitive. /M kilobytes Specifies the amount of main memory used for sorting, in KB. The minimum amount of memory is always 160 KB. If a memory size is specified, regardless of the available amount of main memory, the specified amount of memory will all be used for sorting. For best performance, usually do not specify a memory size. By default, if the default maximum memory value is reached, sorting is completed in one pass (non-temporary file); otherwise, sorting is completed in two passes (data not fully sorted is stored in a temporary file); the amounts of memory used for sorting and merging are equal. If input and output are both files, the default maximum memory is 90% of available main memory; otherwise, it is 45% of main memory. /REC characters Specifies the maximum number of characters in a record (default is 4096, maximum is 65535). /R Reverses the sort order, i.e., from Z to A, then from 9 to 0. filename1 Specifies the file to sort. If not specified, standard input is sorted. Specifying an input file is faster than redirecting the same file as standard input. /T Specifies the directory path for holding sort work storage, in case the data cannot fit in main memory. The default is to use the system temporary directory. /O filename3 Specifies the file in which to store the sorted input. If not specified, the data is written to standard output. Specifying an output file is faster than redirecting standard output to the same file. --------------------------------------------------------------- Starts another window to run the specified program or command. START "title" Title to display in the window title bar. path Starting directory B Starts the application without creating a new window. Unless ^C handling is enabled, the application ignores ^C handling; ^Break is the only way to interrupt the application I The new environment is the original environment passed to cmd.exe, not the current environment MIN Starts with the window minimized MAX Starts with the window maximized SEPARATE Starts a 16-bit Windows program in a separate space SHARED Starts a 16-bit Windows program in a shared space LOW Starts the application in the IDLE priority class NORMAL Starts the application in the NORMAL priority class HIGH Starts the application in the HIGH priority class REALTIME Starts the application in the REALTIME priority class ABOVENORMAL Starts the application in the ABOVENORMAL priority class BELOWNORMAL Starts the application in the BELOWNORMAL priority class WAIT Starts the application and waits for it to end command/program If it is an internal cmd command or batch file, the command processor runs cmd.exe with the /K command option. This means the window remains after the command runs. If it is not an internal cmd command or batch file, it is a program and runs as a windowed application or console application. parameters These are parameters passed to the command/program If command extensions are enabled, invocation of external commands through the command line or the START command changes as follows: When a file name is typed as a command, non-executable files can be invoked through file associations. (For example, WORD.DOC invokes the application associated with the .DOC file extension). For how to create these associations from within a command script, see the ASSOC and FTYPE commands. When the application executed is a 32-bit GUI application, CMD.EXE returns to the command prompt without waiting for the application to terminate. This new behavior does not occur if executed within a command script. If the first token of the command line executed is the string "CMD" without an extension or path qualifier, "CMD" is replaced by the value of the COMSPEC variable. This prevents CMD.EXE from being picked up from the current directory. If the first token of the command line executed has no extension, CMD.EXE uses the value of the PATHEXT environment variable to determine which extensions to look for and in what order. The default value of the PATHEXT variable is: .COM;.EXE;.BAT;.CMD Note that the syntax is the same as the PATH variable, with semicolons separating the different elements. When searching for an executable file, if no matching extension is found, check whether the name matches a directory name. If it does, START invokes Explorer on that path. If executed from the command line, this is equivalent to doing CD /D on that path. |
|
| Floor10 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
-
--------------------------------------------------------------- Associates a path with a drive letter. SUBST path] SUBST drive1: /D drive1: Specifies the virtual drive to assign the path to. path Specifies the physical drive and the path to assign to the virtual drive. /D Deletes the substituted (virtual) drive. Type SUBST without any parameters to display the current list of virtual drives. --------------------------------------------------------------- Displays or sets the system time. TIME Type TIME without parameters to display the current time setting and prompt you to enter a new time setting. Press ENTER to keep the original time. If command extensions are enabled, the DATE command supports the /T command option; this command option tells the command to output only the current time without prompting for a new time. --------------------------------------------------------------- Sets the window title of the command prompt window. TITLE string Specifies the title of the command prompt window. --------------------------------------------------------------- Graphically displays the folder structure of a drive or path. TREE /F Displays the names of the files in each folder. /A Uses ASCII characters instead of extended characters. --------------------------------------------------------------- Displays the contents of a text file. TYPE filename --------------------------------------------------------------- Displays the Windows 2000 version. VER --------------------------------------------------------------- Tells cmd.exe whether to verify that files have been written correctly to disk. VERIFY Type VERIFY without parameters to display the current VERIFY setting. --------------------------------------------------------------- |
|
| Floor11 ko20010214 | Posted 2003-06-01 00:00 |
| 版主 Posts 1,628 Credits 7,296 | |
|
Displays the disk volume label and serial number (if present).
VOL --------------------------------------------------------------- Copies files and directory trees. XCOPY source ] ] ...] source Specifies the files to copy. destination Specifies the location and/or name of the new files. /A Copies only files with the archive attribute set, but does not change the attribute. /M Copies only files with the archive attribute set, and turns off the archive attribute. /D:m-d-y Copies files changed on or after the specified date. If no date is provided, copies only those files whose source time is newer than the destination time. /EXCLUDE:file1... Specifies a list of files containing strings. If any string matches the absolute path of a file to be copied, that file will not be copied. For example, specifying strings such as \obj\ or .obj excludes all files under the obj directory or files with the .obj extension. /P Prompts before creating each destination file. /S Copies directories and subdirectories, except empty ones. /E Copies directories and subdirectories, including empty ones. Same as /S /E. Can be used to modify /T. /V Verifies each new file. /W Prompts you to press a key before copying. /C Continues copying even if errors occur. /I If the destination does not exist and more than one file is being copied, assumes that the destination must be a directory. /Q Does not display file names while copying. /F Displays full source and destination file names while copying. /L Displays the files that would be copied. /H Also copies hidden and system files. /R Overwrites read-only files. /T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories. /U Copies only files that already exist in the destination. /K Copies attributes. Normal Xcopy resets read-only attributes. /N Copies using generated short names. /O Copies file ownership and ACL information. /X Copies file audit settings (implies /O). /Y Suppresses prompting to confirm overwriting an existing destination file. /-Y Causes prompting to confirm overwriting an existing destination file. /Z Copies network files in restartable mode. The /Y command option can be preset in the COPYCMD environment variable. This can be overridden by /-Y on the command line. --------------------------------------------------------------- -- ※ Source: ·BBS Shuimu Tsinghua Station smth.org· (This article was copied using the S-Term article copy script) ================================================== |
|
| Floor12 junyee | Posted 2006-06-01 18:30 |
| 中级用户 Posts 112 Credits 253 | |
|
Seems like this is just the stuff you get with /? in a DOS window. But putting it all together really is very convenient.
|
|
| Floor13 JD | Posted 2010-06-24 16:35 |
| 新手上路 Posts 5 Credits 6 From 南京 | |
|
Still, supporting it
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |