p
Accessibility Settings
This is a short cut to start up the ACCESSIBILITY Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
ACCESS.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Miscellaneous Windows Keys
These key combinations are available in Windows to reach certain Accessibility Options.
Add/Remove Programs
This is a short cut to start up the ADD/REMOVE PROGRAMS portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
APPWIZ.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Advanced tab of System Properties
This is a short cut to start up the System Properties dialog and go to the Advanced tab.
This is the tab that has the button 'Environment Variables' which is where one would go
to modify the system PATH.
Either make a shortcut on the desktop with this or do START then RUN then type in
'sysdm.cpl,@0,3' and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
ALT-TAB Keys
Toggle through the applications open on the Task Bar
Holding down the ALT key then continually striking the TAB key will popup a small box
that contains an icon for each of the applications that are open on the Task Bar. The
description of the application currently in focus (denoted by a box drawn around the
icon) will display at the bottom of the popup.
The combination of the SHIFT Key and the TAB Key will make the box move in the
opposite direction.
AT Schedules commands and programs to run on a computer at a specified time and date. at [\\ComputerName] [{[ID] [/delete]|/delete [/yes]}] at [[\\ComputerName] hours:minutes [/interactive] [{/every:date[,...]|/next:date[,...]}] command] Parameters: - \\ComputerName
ATTRIB Displays, sets, or removes the read-only, archive, system, and hidden attributes assigned to files or directories. attrib [{+r|-r}] [{+a|-a}] [{+s|-s}] [{+h|-h}] [[Drive:][Path] FileName] [/s[/d]] Parameters: - +r -- Sets the read-only file attribute. - -r -- Clears the read-only file attribute. - +a -- Sets the archive file attribute. - -a -- Clears the archive file attribute. - +s -- Sets the system file attribute. - -s -- Clears the system file attribute. - +h -- Sets the hidden file attribute. - -h -- Clears the hidden file attribute. - [Drive:][Path] FileName -- Specifies the location and name of the directory, file, or set of files to display or change attributes. Wildcard characters (i.e. ? and *) can be used in the FileName parameter to display or change the attributes for a group of files. - /s -- Applies attrib and any command-line options to matching files in the current directory and all of its subdirectories. - /d -- Applies attrib and any command-line options to directories. - /? -- Displays help at the command prompt. Remarks: - Used without parameters, attrib displays attributes of all files in the current directory. Working with groups of files: ============================= Wildcard characters (i.e. ? and *) can be used with the FileName parameter to display or change the attributes for a group of files. File with the system or hidden attribute set must have the attributes cleared before changing any other attributes for that file. Using the archive attribute: ============================ - The archive attribute (i.e. +a) marks files that have changed since the last time they were backed up. The xcopy command uses archive attributes. For more information about archive attributes and xcopy, see Related Topics. - The attrib command, with different parameters, is available from the Recovery Console. Examples: - To display the attributes of a file named News86 located on the current drive, type: attrib news86 - To assign the read-only attribute to the file named Report.txt, type: attrib +r report.txt - To remove the read-only attribute from files in the \Public\Jones directory on a disk in drive B and from files in any subdirectories of \Public\Jones, type: attrib -r b:\public\jones\*.* /s - Consider a scenario to give an associate a disk containing all files in the default directory on a disk in drive A, except files with the .bak extension. Because xcopy can be used to copy only those files marked with the archive attribute, set the archive attribute for those files to be copied. First, set the archive attribute for all files on drive A. Second, clear the archive attribute for those files with the .bak extension. For example, type: attrib +a a:*.* attrib -a a:*.bak - Next, use xcopy to copy the files from the disk in drive A to the disk in drive B. The /a command-line option in the following command causes xcopy to copy only those files marked with the archive attribute. For example, type: xcopy a: b: /a - To have xcopy clear each file's archive attribute after it copies the files, use the /m command-line option instead of /a. For example, type: xcopy a: b: /m
BATCH PARAMETERS Batch parameters can be used anywhere within a batch file to extract information about environment settings. Cmd.exe provides the batch parameter expansion variables %0 through %9. When batch parameters are used in a batch file, %0 is replaced by the batch file name, and %1 through %9 are replaced by the corresponding arguments typed at the command line. To access arguments beyond %9, use the shift command. For more information about the shift command, see Shift The %* batch parameter is a wildcard reference to all the arguments, not including %0, that are passed to the batch file. For example, to copy the contents from Folder1 to Folder2, where %1 is replaced by the value Folder1 and %2 is replaced by the value Folder2, type the following in a batch file called Mybatch.bat: xcopy %1\*.* %2 To run the file, type: mybatch.bat C:\folder1 D:\folder2 This has the same effect as typing the following in the batch file: xcopy C:\folder1 \*.* D:\folder2 Modifiers can be used with batch parameters. Modifiers use current drive and directory information to expand the batch parameter as a partial or complete file or directory name. To use a modifier, type the percent (%) character followed by a tilde (~) character, and then type the appropriate modifier (i.e. %~modifier). The following table lists the modifiers available to use in expansion. Modifier - Description %~1 - Expands %1 and removes any surrounding quotation marks (""). %~f1 - Expands %1 to a fully qualified path name. %~d1 - Expands %1 to a drive letter. %~p1 - Expands %1 to a path. %~n1 - Expands %1 to a file name. %~x1 - Expands %1 to a file extension. %~s1 - Expanded path contains short names only. %~a1 - Expands %1 to file attributes. %~t1 - Expands %1 to date and time of file. %~z1 - Expands %1 to size of file. %~$PATH:1 - Searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found, this modifier expands to the empty string. The following table lists possible combinations of modifiers and qualifiers that can be used to get compound results. Modifier - Description %~dp1 - Expands %1 to a drive letter and path. %~nx1 - Expands %1 to a file name and extension. %~dp$PATH:1 - Searches the directories listed in the PATH environment variable for %1 and expands to the drive letter and path of the first one found. %~ftza1 - Expands %1 to a dir-like output line. Note: In the above examples, %1 and PATH can be replaced with other batch parameter values. The %* modifier is a unique modifier that represents all arguments passed in a batch file. This modifier cannot be used in combination with the %~ modifier. The %~ syntax must be terminated by a valid argument value. Batch parameters cannot be manipulated in the same manner as manipulating environment variables. Substrings values cannot be searched and replaced or examineed. However, a parameter can be assigned to an environment variable which can then be manipulated. Examples: If "%~1"=="" GoTo TheParamIsEmpty echo param-1 value is %~1 GoTo ContinueHere TheParamIsEmpty: echo param-1 is empty ContinueHere: If "%~2"=="Update" GoTo UpdateData GoTo DoReadOnly UpdateData: echo ready to update data DoReadOnly:
BREAK
Sets or Clears Extended CTRL+C checking on DOS system
This is present for Compatibility with DOS systems.
It has no effect under Windows XP.
If Command Extensions are enabled, and running on the Windows XP
platform, then the BREAK command will enter a hard coded breakpoint
if being debugged by a debugger.
CACLS Displays or modifies access control lists (ACLs) of files cacls FileName [/t] [/e] [/c] [/g User:permission] [/r User [...]] [/p User:permission [...]] [/d User [...]] Parameters: - FileName -- Required. Displays DACLs of specified files. - /t -- Changes DACLs of specified files in the current directory and all subdirectories. - /e -- Edits a DACL instead of replacing it. - /c -- Continues to change DACLs, ignoring errors. - /g User:permission -- Grants access rights to the specified user. The following table lists valid values for permission. Value - Description n - None r - Read w - Write c - Change (Write) f - Full Control - /r User -- Revokes access rights for the specified user. - /p User:permission -- Replaces access rights for the specified user. The following table lists valid values for permission. Value - Description n - None r - Read w - Write c - Change (Write) f - Full Control - /d User -- Denies access for the specified user. - /? -- Displays help at the command prompt. Remarks: Use the following table to interpret the results. Output - ACE applies to OI - This folder and files CI - This folder and subfolders IO - The ACE does not apply to the current file/directory. No output message - This folder only (IO)(CI) - This folder, subfolders and files (OI)(CI)(IO) - Subfolders and files only (CI)(IO) - Subfolders only (OI)(IO) - Files only Wildcards (i.e., ? and *) can be used to specify multiple files. More than one user can be specified.
CALL Calls one batch program from another call [[Drive:][Path] FileName [BatchParameters]] [:label [arguments]] Parameters: - [Drive:][Path] FileName -- Specifies the location and name of the batch program to call. The FileName parameter must have a .bat or .cmd extension. - BatchParameters -- Specifies any command-line information required by the batch program, including command-line options, file names, batch parameters (i.e. %0 through %9), or variables (for example, %baud%). - :label -- Specifies the label to which the batch program control should jump. By using call with this parameter, a new batch file context is created and control is passed to the statement after the specified label. The first time the end of the batch file is encountered (i.e. after jumping to the label), control returns to the statement after the call statement. The second time the end of the batch file is encountered, the batch script is exited. For a description of the goto :eof extension that returns from (i.e. out of) a batch script, see Related Topics. - arguments -- Specifies any command-line information to pass to the new instance of the batch program that begins at :label, including command-line options, file names, batch parameters (i.e. %1 through %9), or variables (for example, %baud%). - /? -- Displays help at the command prompt. Remarks: Batch parameters can contain any information that is passed to a batch program, including command-line options, file names, batch parameters (i.e. %0 through %9) and variables (for example, %baud%). For more information about batch parameters, see Related Topics. Do not use pipes and redirection symbols with call. A batch program can call itself, however, an exit condition must be provided. Otherwise, the parent and child batch programs can loop endlessly. With command extensions enabled (i.e. the default), call accepts a label as the target of the call. The correct syntax is as follows: call :label arguments In addition, expansion of batch script argument references (%0, %1, etc.) have been changed as follows: %* in a batch script refers to all the arguments (e.g. %1 %2 %3 %4 %5 ...) Substitution of batch parameters (%n) has been enhanced. Use the following optional syntax: %~1 - expands %1 removing any surrounding quotes (") %~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 only %~a1 - expands %1 to file attributes %~t1 - expands %1 to date/time of file %~z1 - expands %1 to size of file %~$PATH:1 - searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string The modifiers can be combined to get compound results: %~dp1 - expands %1 to a drive letter and path only %~nx1 - expands %1 to a file name and extension only %~dp$PATH:1 - searches the directories listed in the PATH environment variable for %1 and expands to the drive letter and path of the first one 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 may not be used with %* For more information about enabling and disabling command extensions, see cmd in Related Topics. Examples: - To run the Checknew.bat program from another batch program, type the following command in the parent batch program: call checknew - If the parent batch program accepts two batch parameters and those parameters need to be passed to Checknew.bat, use the following command in the parent batch program: call checknew %1 %2
CD Displays the name of, or changes the, current directory. cd [[/d] [Drive:][Path] [..]] [[/d] [Drive:][Path] [..]] Parameters: - /d -- Changes the current drive or the current directory for a drive. - [drive:][Path] -- Specifies the drive (i.e. if it is different from the current drive) and directory to which to change. - [..] -- Specifies to change to the parent folder. - /? -- Displays help at the command prompt. Remarks: Used with only a drive letter (for example, cd C:), cd displays the names of the current drive and folder. Used without parameters, cd displays the current drive and directory. Working with command extensions: ================================ With command extensions enabled (i.e. the default), the current directory path matches the folder names exactly as they appear on the hard drive, using the same uppercase or lowercase folder-name format. For example, if the folder on the hard drive is called C:\Temp, CD C:\TEMP sets the current directory to C:\Temp to match the folder-name format of the folder on the hard drive. To disable command extensions for a particular process, type: cmd e:off When command extensions are disabled, cd does not treat white spaces as delimiters. As a result, it is possible to change to a subdirectory name that contains a white space without having to surround [Path] in quotation marks. For example, the following path changes to the \Start menu subdirectory: cd \winnt\profiles\username\programs\start menu For more information about enabling and disabling command extensions, see cmd in Related Topics. Changing to the root directory: =============================== The root directory is the top of the directory hierarchy for a drive. To return to the root directory, type: cd\ Changing the default directory on one drive from another drive: =============================================================== To change the default directory on a drive different from the current one, type one of the following: cd [Drive:\[directory]] To verify the change to the directory, type one of the following: cd [Drive:] The cd command, with different parameters, is available from the Recovery Console. Examples: When used with a drive name, cd displays the current directory for that drive. For example, cd c: at the C:\Temp directory prompt, the following appears: C:\Temp To change the current directory to a directory named Reports, type one of the following commands: cd \reports To change the current directory to a subdirectory \Specials\Sponsors, type: cd \specials\sponsors Or, if the current directory is \Specials, type the following command to change to the \Specials\Sponsors subdirectory: cd sponsors To change from a subdirectory to its parent directory, type: cd .. To display the name of the current directory, use cd or cd without a parameter. For example, if the current directory is \Public\Jones on drive B, typing cd the following appears: B:\Public\Jones If currently on drive D and want to copy all files in the \Public\Jones and \Public\Lewis directories on drive C to the root directory on drive D, type: cd c:\public\jones copy c:*.* d:\ cd c:\public\lewis copy c:*.* d:\ To copy all files in the \Public\Jones and \Public\Lewis directories to the current location on drive D, type: cd c:\public\jones copy c:*.* d: cd c:\public\lewis copy c:*.* d:
CharMap Displays a grid of 240 characters for the selected font. charmap Parameters: - None Remarks: Any character in the grid can be selected and optionally selected then copied (into the Windows clipboard) then pasted into any other application that accepts character entry. The font can be changed by selecting a different one in the drop down list at the top. When the font is changed, the characters in the grid take on the appearance of the newly selected font.
CHCP Displays the number of the active console code page, or changes the console's active console code page. chcp [nnn] Parameters: - nnn -- Specifies the code page. The following table lists each code page supported and its country/region or language: Code page - Country/region or language 437 - United States 850 - Multilingual (Latin I) 852 - Slavic (Latin II) 855 - Cyrillic (Russian) 857 - Turkish 860 - Portuguese 861 - Icelandic 863 - Canadian-French 865 - Nordic 866 - Russian 869 - Modern Greek - /? -- Displays help at the command prompt. Remarks: Used without parameters, chcp displays the number of the active console code pages. Only the original equipment manufacturer (OEM) code page installed with Windows XP appears correctly in a command prompt window that uses Raster fonts. Other code pages appear correctly in full-screen mode or command prompt windows that use TrueType fonts. Code pages do not need to be prepared as they do in MS-DOS. Programs that start after they are assigned a new code page use the new code page, however, programs (except Cmd.exe) that were started before assigning the new code page use the original code page. Examples: To view the active code page setting, type: chcp A message similar to the following appears: Active code page: 437 To change the active code page to 850 (Multilingual), type: chcp 850 If the specified code page is invalid, the following error message appears: Invalid code page
CHDIR
Displays the name of, or changes the current, directory.
See CD
CHKDSK Checks a disk and displays a status report. chkdsk [volume:][[Path] FileName] [/f] [/v] [/r] [/x] [/i] [/c] [/l[:size]] Parameters: - volume: -- Specifies the drive letter (followed by a colon), mount point, or volume name. - [Path] FileName -- Specifies the location and name of a file or set of files that chkdsk is to check for fragmentation. Wildcard characters (i.e. * and ?) can be used to specify multiple files. - /f -- Fixes errors on the disk. The disk must be locked. If chkdsk cannot lock the drive, a message appears asking if to check the drive the next time the computer is restarted. - /v -- Displays the name of each file in every directory as the disk is checked. - /r -- Locates bad sectors and recovers readable information. The disk must be locked. - /x -- Use with NTFS only. Forces the volume to dismount first, if necessary. All open handles to the drive are invalidated. /x also includes the functionality of /f. - /i -- Use with NTFS only. Performs a less vigorous check of index entries, reducing the amount of time needed to run chkdsk. - /c -- Use with NTFS only. Skips the checking of cycles within the folder structure, reducing the amount of time needed to run chkdsk. - /l[:size] -- Use with NTFS only. Changes the log file size to the size specified. If the size parameter is omitted, /l displays the current size. - /? -- Displays help at the command prompt. Remarks: Chkdsk also lists and corrects errors on the disk. Used without parameters, chkdsk displays the status of the disk in the current drive. Running chkdsk ============== Running chkdsk on a fixed disk must be done by a member of the Administrators group. Checking a locked drive at restart: =================================== To have chkdsk correct disk errors, no files on the drive can be open. If files are open, the following error message appears: Chkdsk cannot run because the volume is in use by another process. Would you like to schedule this volume to be checked the next time the system restarts? (Y/N) If choose to check the drive the next time the computer os restarted, chkdsk checks the drive and corrects errors automatically when the computer is restarted. If the drive partition is a boot partition, chkdsk automatically restarts the computer after it checks the drive. Reporting disk errors: ====================== Chkdsk examines disk space and disk use for the file allocation table (FAT) and NTFS file systems. Chkdsk provides information specific to each file system in a status report. The status report shows errors found in the file system. Running chkdsk without the /f command-line option on an active partition might report spurious errors because it cannot lock the drive. Use chkdsk on occasion to check each disk for errors. Fixing disk errors: =================== Chkdsk corrects disk errors only if the /f command-line option is specified. Chkdsk must be able to lock the drive to correct errors. Because repairs usually change a disk's file allocation table and sometimes cause a loss of data, chkdsk sends a confirmation message similar to the following: 10 lost allocation units found in 3 chains. Convert lost chains to files? If press Y, Windows saves each lost chain in the root directory as a file with a name in the format Filennnn.chk. When chkdsk finishes, these files can be checked to see if they contain any needed data. If press N, Windows fixes the disk, but it does not save the contents of the lost allocation units. If the /f command-line option is not used, chkdsk sends a message if a file needs to be fixed, but it does not fix any errors. If chkdsk /f is used on a very large disk (for example, 70 gigabytes) or a disk with a very large number of files (for example, millions of files), chkdsk might take a long time (for example, over several days) to complete. The computer is not available during this time because chkdsk does not relinquish control until it is finished. Checking a FAT disk: ==================== Windows displays chkdsk status reports for a FAT (File Allocation System, use before before Windows 2000) disk in the following format: Volume Serial Number is B1AF-AFBF 72214528 bytes total disk space 73728 bytes in 3 hidden files 30720 bytes in 12 directories 11493376 bytes in 386 user files 61440 bytes in bad sectors 60555264 bytes available on disk 2048 bytes in each allocation unit 35261 total allocation units on disk 29568 available allocation units on disk Checking an NTFS disk: ====================== Windows displays chkdsk status reports for an NTFS (New Technology File System, for Windows NT and Windows 2000 and after) disk in the following format: The type of the file system is NTFS. CHKDSK is verifying files... File verification completed. CHKDSK is verifying indexes... Index verification completed. CHKDSK is verifying security descriptors... Security descriptor verification completed. 12372 kilobytes total disk space. 3 kilobytes in 1 user files. 2 kilobytes in 1 indexes. 4217 kilobytes in use by the system. 8150 kilobytes available on disk. 512 bytes in each allocation unit. 24745 total allocation units on disk. 16301 allocation units available on disk. Using chkdsk with open files: ============================= If the /f command-line option isspecified, chkdsk sends an error message if there are open files on the disk. If the /f command-line option is not specified and open files exist, chkdsk might report lost allocation units on the disk. This could happen if open files have not yet been recorded in the file allocation table. If chkdsk reports the loss of a large number of allocation units, consider repairing the disk. Finding physical disk errors: ============================= Use the /r command-line option to find physical disk errors in the file system. For information about recovering physically damaged files with recover, see Related Topics. Reporting bad disk sectors: =========================== Bad sectors reported by chkdsk were marked as bad when the disk was first prepared for operation. They pose no danger. Understanding exit codes: ========================= The following table lists the exit codes that chkdsk reports after it has finished. Exit code - Description 0 - No errors were found. 1 - Errors were found and fixed. 2 - Disk cleanup, such as garbage collection, was performed, or cleanup was not performed because /f was not specified. 3 - Could not check the disk, errors could not be fixed, or errors were not fixed because /f was not specified. The chkdsk command, with different parameters, is available from the Recovery Console. Examples: To check the disk in drive D and have Windows fix errors, type: chkdsk d: /f If it encounters errors, chkdsk pauses and displays messages. Chkdsk finishes by displaying a report that lists the status of the disk. Files on the specified drive cannot be opened until chkdsk finishes. To check all of files on a FAT disk in the current directory for noncontiguous blocks, type: chkdsk *.* Chkdsk displays a status report, and then lists the files matching the file specification that have noncontiguous blocks.
CHKNTFS Displays or specifies whether automatic system checking is scheduled to be run on a FAT, FAT32, or NTFS volume when the computer is started. chkntfs volume: [...] chkntfs [/d] chkntfs [/t[:time]] chkntfs [/x volume: [...]] chkntfs [/c volume: [...]] Parameters: - volume: [...] -- Required. Specifies the drive letter (followed by a colon), mount point, or volume name. Displays a message that identifies the file system of the specified volume. If automatic file checking is scheduled to be run, this parameter displays a message indicating whether the volume has been corrupted, which requires chkdsk to be run. - /d -- Restores all chkntfs default settings, except the countdown time for automatic file checking. Default behavior is to check all volumes when the computer is started. - /t[:time] -- Changes the Autochk.exe initiation countdown time to the specified amount of time entered in seconds. If :time is not specified then /t displays the current countdown time. - /x volume: [...] -- Excludes the specified volume from being checked when the computer starts, even if the volume is marked as requiring chkdsk. - /c volume: [...] -- Schedules the specified volume to be checked when the computer starts. - /? -- Displays help at the command prompt. Remarks: chkntfs can only be run by a member of the Administrators group. If no parameters are specified, CHKNTFS will display if the specified drive is dirty or scheduled to be checked on next reboot. Although the Autochk.exe initiation countdown time can be set to zero, a potentially time- consuming automatic file check cannot be cancelled if it is set to zero. Examples: To display the Autochk.exe initiation countdown time, type: chkntfs /t When changing the Autochk.exe initiation countdown time, type the time in seconds. For example, to change the countdown time to 30 seconds, type: chkntfs /t:30 The /x command-line option is not accumulative. If it is typed more than once, the most recent entry overrides the previous entry. To exclude multiple volumes, list them all in one command. For example, to exclude both the E: and F: volumes, type: chkntfs /x e: f: To exclude the F: volume only, type: chkntfs /x e: chkntfs /x f: The /c command-line option is accumulative. To check the specified volume only, reset the defaults to clear any previous commands, exclude all volumes from being checked, and then schedule automatic file checking on the desired volume. For example, to schedule automatic file checking on the D: volume only, type: chkntfs /d chkntfs /x c: d: e: chkntfs /c d:
CLS
Clears the screen.
CLS
CMD Starts a new instance of the command interpreter, Cmd.exe. Used without parameters, cmd displays Windows XP version and copyright information. cmd [[{/c|/k}] [/s] [/q] [/d] [{/a|/u}] [/t:fg] [/e:{on|off}] [/f:{on|off}] [/v:{on|off}] string] Parameters: - /c -- Carries out the command specified by string and then stops. - /r -- Carries out the command specified by string and then stops. - /k -- Carries out the command specified by string and continues. - /s -- Modifies the treatment of string after /c or /k. - /q -- Turns the echo off. - /d -- Disables execution of AutoRun commands. - /a -- Creates American National Standards Institute (ANSI) output. - /u -- Creates Unicode output. - /t:fg -- Sets the foreground f and background g colors. The following tables lists valid hexadecimal digits available to use as the values for f and g. Value - Color Value - Color 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 - /e:on -- Enables command extensions. - /e:off -- Disables commands extensions. - /x -- Enables command extensions. - /y -- Disables commands extensions. - /f:on -- Enables file and directory name completion. - /f:off -- Disables file and directory name completion. - /v:on -- Enables delayed environment variable expansion. - /v:off -- Disables delayed environment variable expansion. - string -- Specifies the command to carry out. - /? -- Displays help at the command prompt. Remarks: ALT plus ENTER keys will toggle the command prompt between full-screen mode and back to its default size mode. Using multiple commands (command chaining): =========================================== Multiple commands are separated by the command separator && for string, but they must enclose them in quotation marks (for example, "command&&command&&command"). Processing quotation marks: =========================== If specify /c or /k, cmd processes the remainder of string and quotation marks are preserved only if all of the following conditions are met: - You do not use /s. - Use exactly one set of quotation marks. - Do not use any special characters within the quotation marks (ex.: &<>( ) @ ^ |). - Use one or more white-space characters within the quotation marks. - The string within quotation marks is the name of an executable file. If the previous conditions are not met, string is processed by examining the first character to verify whether or not it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved. Or, to put it another way, if /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters: 1. If all of the following conditions are met, then quote characters on the command line are preserved: - no /S switch - exactly two quote characters - no special characters between the two quote characters, where special is one of: &<>()@^| - there are one or more whitespace characters between the the two quote characters - the string between the two quote characters is the name of an executable file. 2. Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character. Executing registry subkeys: =========================== If /d is not specified in string, Cmd.exe looks for the following registry subkeys: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun\REG_SZ HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun REG_EXPAND_SZ If either one or both registry subkeys are present, they are executed before all other variables. Caution: Incorrectly editing the registry may severely damage the system. Before making changes to the registry, back up any valued data on the computer. Enabling and disabling command extensions: ========================================== Command extensions are enabled by default in Windows XP. They can be disabled for a particular process by using /e:off. Extensions can be enabled or disabled for all cmd command-line options on a computer or user session by setting the following REG_DWORD values: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions\REG_DWORD Set the REG_DWORD value to either 0×1 (i.e. enabled) or 0×0 (i.e. disabled) in the registry by using Regedit.exe. User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings. Caution: Incorrectly editing the registry may severely damage the system. Before making changes to the registry, back up any valued data on the computer. When enabling command extensions, the following commands are affected: assoc if call md (mkdir) cd (chdir) popd color prompt del (erase) pushd endlocal set for setlocal ftype shift goto start (also includes changes to external command invocation) For more information about these commands, see Related Topics. Enabling delayed environment variable expansion: ================================================ If delayed environment variable expansion is enabled, use the exclamation character to substitute the value of an environment variable at run time. Enabling file and directory name completion: ============================================ File and directory name completion is not enabled by default. Enable or disable file name completion for a particular process of the cmd command with /f:{on|off}. Enable or disable file and directory name completion for all processes of the cmd command on a computer or user logon session by setting the following REG_DWORD values: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD To set the REG_DWORD value, run Regedit.exe and use the hexadecimal value of a control character for a particular function (for example, 0×9 is TAB and 0×08 is BACKSPACE). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings. Caution: Incorrectly editing the registry may severely damage the system. Before making changes to the registry, back up any valued data on the computer. If enable file and directory name completion by using /f:on, use CTRL+D for directory name completion and CTRL+F for file name completion. To disable a particular completion character in the registry, use the value for white space [0×20] because it is not a valid control character. When press CTRL+D or CTRL+F, cmd processes file and directory name completion. These key combination functions append a wildcard character to string (i.e. if one is not present), build a list of paths that match, and then display the first matching path. If none of the paths match, the file and directory name completion function beeps and does not change the display. To move through the list of matching paths, press CTRL+D or CTRL+F repeatedly. To move through the list backwards, press the SHIFT key and CTRL+D or CTRL+F simultaneously. To discard the saved list of matching paths and generate a new list, edit string and press CTRL+D or CTRL+F. If switch between CTRL+D and CTRL+F, the saved list of matching paths is discarded and a new list is generated. The only difference between the key combinations CTRL+D and CTRL+F is that CTRL+D only matches directory names and CTRL+F matches both file and directory names. If use file and directory name completion on any of the built-in directory commands (i.e. CD, MD, or RD), directory completion is assumed. File and directory name completion correctly processes file names that contain whitespace or special characters if place quotation marks around the matching path. The following special characters require quotation marks: & < > [ ] { } ^ = ; ! ' + , ` ~ [white space] If the supplied information contains spaces, use quotation marks around the text (ex. "Computer Name"). If process file and directory name completion from within string, any part of the [Path] to the right of the cursor is discarded (i.e. at the point in string where the completion was processed).
COLOR Changes the Command Prompt window foreground and background colors for the current session. color [fb] Parameters: - fb -- Sets the foreground f and background g colors. The following tables lists valid hexadecimal digits that can be used as the values for f and g. Value - Color 0 - Black 1 - Blue 2 - Green 3 - Aqua 4 - Red 5 - Purple 6 - Yellow 7 - White 8 - Gray 9 - Light blue A - Light green B - Light aqua C - Light red D - Light purple E - Light yellow F - Bright white - /? -- Displays help at the command prompt. Remarks: Used without parameters, color restores the default Command Prompt window foreground and background colors as set when CMD.EXE was started. This value either comes from the current console window, the /T command line switch or from the DefaultColor registry value. To set the default Command Prompt window color, click the upper-left corner of the command prompt window, click Defaults, click the Colors tab, and then click the colors that to use for the Screen Text and Screen Background. Use cmd /t:fb to change the Command Prompt window colors for the current session. If the foreground and background colors are the same, the color command sets ERRORLEVEL to one (1). Examples: To change the Command Prompt window foreground color to red and background to white, type: color FC
COMP Compares the contents of two files, or sets of files, byte by byte. comp [data1] [data2] [/d] [/a] [/l] [/n=number] [/c] Parameters: - data1 -- Specifies the location and name of the first file or set of files to compare. Wildcard characters (* and ?) can be used to specify multiple files. - data2 -- Specifies the location and name of the second file or set of files to compare. Wwildcard characters (* and ?) can be used to specify multiple files. - /d -- Displays differences in decimal format. (The default format is hexadecimal.) - /a -- Displays differences as characters. - /l -- Displays the number of the line on which a difference occurs, instead of displaying the byte offset. - /n=number -- Compares the first number of lines of both files, even if the files are different sizes. - /c -- Performs a comparison that is not case-sensitive. - /? -- Displays help at the command prompt. Remarks: Comp can compare files on the same drive or on different drives, and in the same directory or in different directories. When comp compares the files, it displays their locations and file names. Used without parameters, comp prompts the entry of the files to compare. Comparing files with the same names: ==================================== The compared files can have the same file name, provided they are in different directories or on different drives. If a name for data2 is not specified, the default file name for data2 is the same as the file name in data1. Wwildcard characters (i.e. * and ?) can be used to specify file names. Special cases for data1 and data2 ================================== If necessary components of either data1 or data2 are omitted or data2 is omitted, comp prompts for the missing information. If data1 contains only a drive letter or a directory name with no file name, comp compares all of the files in the specified directory to the file specified in data2. If data2 contains only a drive letter or a directory name, the default file name for data2 is the same as that in data1. How the comp command identifies mismatching information: ======================================================== During the comparison, comp displays messages to identify the locations of unequal information in the two files. Each message indicates the offset memory address of the unequal bytes and the contents of the bytes themselves (i.e. in hexadecimal notation unless the /a or /d command-line options are specified). The message appears in the following format: Compare error at OFFSET xxxxxxxx file1 = xx file2 = xx After 10 unequal comparisons, comp stops comparing the files and displays the following message: 10 Mismatches - ending compare Comparing files of different sizes: =================================== Files of different sizes can only be compared if the /n command-line option is specified. If the file sizes are different, comp displays the following message: Files are different sizes Compare more files (Y/N)? Press Y to compare another pair of files. Press N to stop the comp command. Pressing Y in response to the prompt tells comp to include any command-line options specified on the command line for every comparison it makes unless N is pressed or the command is retyped. When comparing files of different sizes, use the /n command-line option to compare only the first portion of each file. Comparing files sequentially: ============================= If wildcard characters (* and ?) are used to specify multiple files, comp finds the first file matching data1 and compares it with the corresponding file in data2, if it exists. The comp command reports the results of the comparison, and then does the same for each file matching data1. When finished, comp displays the following message: Compare more files (Y/N)? To compare more files, press Y. The comp command prompts for the locations and names of the new files. To stop the comparisons, press N. When press Y, comp prompts for command-line options to use. If no command-line options are specified, comp uses the ones specified previously. If comp cannot find the files If comp cannot find the file(s) specified, it prompts a message to determine whether to compare more files. Examples: To compare the contents of the directory C:\Reports with the backup directory \\Sales\Backup\April, type: comp c:\reports \\sales\backup\april To compare the first ten lines of the text files in the \Invoice directory and display the result in decimal format, type: comp \invoice\*.txt \invoice\backup\*.txt /n=10 /d
COMPACT Displays and alters the compression of files or directories on NTFS partitions. compact [{/c|/u}] [/s[:dir]] [/a] [/i] [/f] [/q] [FileName[...]] Parameters: - /c -- Compresses the specified directory or file. - /u -- Uncompresses the specified directory or file. - /s:dir -- Specifies that the requested action (compress or uncompress) be applied to all subdirectories of the specified directory, or of the current directory if none is specified. - /a -- Displays hidden or system files. - /i -- Ignores errors. - /f -- Forces compression or uncompression of the specified directory or file. This is used in the case of a file that was partly compressed when the operation was interrupted by a system crash. To force the file to be compressed in its entirety, use the /c and /f parameters and specify the partially compressed file. - /q -- Reports only the most essential information. - FileName -- Specifies the file or directory. Multiple file names and wildcard characters (* and ?) can be used. - /? -- Displays help at the command prompt. Remarks: Used without parameters, compact displays the compression state of the current directory. The compact command, the command-line version of the NTFS file system compression feature, displays and alters the compression attribute of files and directories on NTFS partitions. The compression state of a directory indicates whether files added to the directory will be automatically compressed. When the compression state of a directory is set, it does not necessarily change the compression state of files that are already there. compact cannot be used to read, write, or mount volumes that have been compressed using DriveSpace or DoubleSpace. Examples: To set the compression state of the current folder and its subfolders and existing files, from the current folder, type: compact /c /s To set the compression state of files in the current folder, subfolders in the current folder, and files within all subfolders without altering the compression state of the current folder, from the current folder, type: compact /c /s *.* To compress a volume, from the root folder of the volume, type: compact /c /i /s:\ This example sets the compression state of the root folder and all folders on the volume and compresses every file on the volume. Using the /i parameter ensures that error messages do not interrupt the compression process. To compress all files that end in .bmp in the \Tmp directory and all subdirectories of \Tmp, but not modify the compressed attribute of these directories, type: compact /c /s:\tmp *.bmp To force complete compression of the file Zebra.bmp, which was partially compressed at the time of a system crash, type: compact /c /f zebra.bmp To remove the compressed attribute from the directory C:\Tmp, but not change the compression state of any files in that directory, type: compact /u c:\tmp
Computer Management
This is a short cut to start up the Computer Management dialog.
Either make a shortcut on the desktop with this or do START then RUN then type in
COMPMGMT.MSC and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
CONVERT
Converts FAT volumes to NTFS.
CONVERT volume /FS:NTFS [/V] [/CvtArea:filename] [/NoSecurity] [/X]
volume Specifies the drive letter (followed by a colon),
mount point, or volume name.
/FS:NTFS Specifies that the volume is to be converted to NTFS.
/V Specifies that Convert should be run in verbose mode.
/CvtArea:filename
Specifies a contiguous file in the root directory to be
the place holder for NTFS system files.
/NoSecurity Specifies the converted files and directories security
settings to be accessible by everyone.
/X Forces the volume to dismount first if necessary.
All opened handles to the volume would then be invalid.
COPY Copies one or more files to another location. copy [/d] [/v] [/n] [{/y|/-y}] [/z] [{/a|/b}] Source [{/a|/b}] [+ Source [{/a|/b}] [+ ...]] [Destination [{/a|/b}]] Parameters: - /d -- Allows the encrypted files being copied to be saved as decrypted files at the destination. - /v -- Verifies that new files are written correctly. - /n -- Uses a short file name, if available, when copying a file with a name longer than eight characters, or with a file extension longer than three characters. - /y -- Suppresses prompting to confirm to overwrite an existing destination file. - /-y -- Prompts to confirm to overwrite an existing destination file. - /z -- Copies networked files in restartable mode. - /a -- Indicates an ASCII text file. - /b -- Indicates a binary file. - Source -- Required. Specifies the location from which to copy a file or set of files. Source can consist of a drive letter and colon, a folder name, a file name, or a combination of these. - Destination -- Required. Specifies the location to copy a file or set of files. Destination can consist of a drive letter and colon, a folder name, a file name, or a combination of these. - /? -- Displays help at the command prompt. Remarks: An ASCII text file that uses an end-of-file character (i.e. CTRL+Z) to indicate the end of the file can be copied. Using /a: ========= When /a precedes a list of files on the command line, it applies to all files listed until copy encounters /b. In this case, /b applies to the file preceding /b. When /a follows a list of files on the command line, it applies to all listed files until copy encounters /b. In this case, /b applies to the file preceding /b. The effect of /a depends on its position in the command-line string. When /a follows Source, copy treats the file as an ASCII file and copies data that precedes the first end-of-file character. When /a follows Destination, copy adds an end-of-file character as the last character of the file. Using /b: ========= /b directs the command interpreter to read the number of bytes specified by the file size in the directory. /b is the default value for copy, unless copy combines files. When /b precedes a list of files on the command line, it applies to all listed files until copy encounters /a. In this case, /a applies to the file preceding /a. When /b follows a list of files on the command line, it applies to all listed files until copy encounters /a. In this case, /a applies to the file preceding /a. The effect of /b depends on its position in the commandline string. When /b follows Source, copy copies the entire file, including any end-of-file character. When /b follows Destination, copy does not add an end-of-file character. Using /v: ========= If a write operation cannot be verified an error message appears. Although recording errors rarely occur with copy, the /v option can be used to verify that critical data has been correctly recorded. The /v command-line option also slows down the copy command, because each sector recorded on the disk must be checked. Using /y and /-y: ================= If /y is preset in the COPYCMD environment variable, it can be overridden by using /-y at the command line. By default, a prompt appends when this setting is replaced unless the copy command is executed in a batch script. Appending files: ================ To append files, specify a single file for Destination, but multiple files for Source (using wildcard characters or file1+file2+file3 format). Using /z: ========= If the connection is lost during the copy phase (for example, if the server going offline severs the connection), copy /z resumes after the connection is reestablished. /z also displays the percentage of the copy operation that is completed for each file. Copying to and from devices: ============================ A device name can be substituted for one or more occurrences of Source or Destination. Using or omitting /b when copying to a device: ============================================== When Destination is a device (for example, Com1 or Lpt1), /b copies data to the device in binary mode. In binary mode, copy /b copies all characters (i.e. including special characters, such as CTRL+C, CTRL+S, CTRL+Z, and carriage return) to the device as data. However, if option /b is omitted, data is copied to the device in ASCII mode. In ASCII mode, special characters might cause Windows XP to combine files during the copying process. For more information, see "Combining files." Using the default destination file: =================================== If a destination file is not specified, a copy is created with the same name, modified date, and modified time as the original file, placing the new copy in the current directory on the current drive. If the source file is on the current drive and in the current directory and a different drive or directory is not specified for the destination file, the copy command stops and displays the following error message: File cannot be copied onto itself 0 File(s) copied Combining files: ================ If more than one Source is specified, separating entries with a plus sign (+), copy combines the files into a single file. Wildcard characters (i.e. * or ?) can be specified in Source, but specifying a single file name in Destination, copy combines all files matching the file name in Source and creates a single file with the file name specified in Destination. In either case, copy assumes the combined files are ASCII files unless the /b option is used. Copying zero-length files: ========================== Copy does not copy files that are 0 bytes long. Use xcopy to copy these files. Changing the time and date of a file: ===================================== To assign the current time and date to a file without modifying the file, use the following syntax: copy /b Source+,, The commas indicate the omission of the Destination parameter. Copying files in subdirectories: ================================ To copy all of a directory's files and subdirectories, use the xcopy command. For information about xcopy, see Related Topics. The copy command, with different parameters, is available from the Recovery Console. Examples: To copy a file called Memo.doc to Letter.doc in the current drive and ensure that an end-of-file character is at the end of the copied file, type: copy memo.doc letter.doc /a To copy a file named Robin.typ from the current drive and directory to an existing directory named Birds that is located on drive C, type: copy robin.typ c:\birds If the Birds directory does not exist, the file Robin.typ is copied into a file named Birds that is located in the root directory on the disk in drive C. To copy several files into one file, list several Source files, separate the file names with a plus sign (+), and specify a Destination file that to contain the resulting combined file. For example, to combine Mar09.rpt, Apr09.rpt, and May09.rpt, which are located on the current drive and directory, and place them in a file named Report on the current drive and directory, type: copy mar09.rpt + apr09.rpt + may09.rpt report When combining files, copy marks the destination file with the current date and time. If Destination is omitted, the files are combined and stored under the name of the file specified first. For example, to combine all four files in Report when a file named Report already exists, type: copy report + mar09.rpt + apr09.rpt + may09.rpt Combining several files into one file can be done by using wildcard characters (i.e. * or ?). For example, to combine all files in the current directory on the current drive that have the extension .txt into one file named Combin.doc, type: copy *.txt combin.doc To combine several binary files into one file by using wildcard characters, include /b. This prevents Windows XP from treating CTRL+Z as an end-of-file character. For example, type: copy /b *.exe combin.exe Caution: ======== If binary files are combined, the resulting file might be unusable due to internal formatting. In the following example, copy combines each file that has a .txt extension with its corresponding .ref file. The result is a file with the same file name but with a .doc extension. Copy combines File1.txt with File1.ref to form File1.doc, and then copy combines File2.txt with File2.ref to form File2.doc, and so on. For example, type: copy *.txt + *.ref *.doc To combine all files with the .txt extension, and then combine all files with the .ref extension into one file named Combin.doc, type: copy *.txt + *.ref combin.doc
DATE Displays or sets the date. DATE [/T | date] Parameters: - mm-dd-yy : Sets the date specified where mm is month, dd is day, and yy is year. - /t : Displays the current date without prompting for a new date. - /? : Displays help at the command prompt. Remarks: The values for mm, dd, and yy must be separated with periods (.), hyphens (-), or slash marks (/). Valid mm values are 1 through 12. Valid dd values are 1 through 31. Valid yy values are 80 through 99, or 1980 through 2099. Windows XP changes the month and year automatically, whether the month has 28, 29, 30, or 31 days. Examples: To change the date to August 3, 2000, type any of the following: 08.03.00 08-03-00 08/03/00 To display the current system date, type: date /t
DEFRAG Locates and consolidates fragmented boot files, data files, and folders on disk drives. defrag volume defrag volume [/a] defrag volume [/a] [/v] defrag volume [/v] defrag volume [/f] Parameters: volume -- The drive letter or a mount point of the volume to be defragmented. /a -- Analyzes the volume and displays a summary of the analysis report. /v -- Displays the complete analysis and defragmentation reports. When used in combination with /a, displays only the analysis report. When used alone, displays both the analysis and defragmentation reports. /f -- Forces defragmentation of the volume regardless of whether it needs to be defragmented. /? -- Displays help at the command prompt. Remarks: - A volume must have at least 15% free space for defrag to completely and adequately defragment it. Defrag uses this space as a sorting area for file fragments. If a volume has less than 15% free space, defrag will only partially defragment it. To increase the free space on a volume, delete unneeded files or move them to another disk. - Volumes marked by defrag as 'dirty' cannot be defragmented since 'dirty' indicates possible corruption. For 'dirty' drives, chkdsk must first be run on them before defragmenting it. The fsutil command can determine if a volume is 'dirty'. - While defrag is analyzing and defragmenting a volume, it displays a blinking cursor. When defrag is finished analyzing and defragmenting the volume, it displays the analysis report, the defragmentation report, or both reports, and then exits to the command prompt. - By default, defrag displays a summary of both the analysis and defragmentation reports if the /a or /v parameters are not specified. - The reports can be sent to a text file by typing >filename.txt, where filename.txt is a specified file name. For example: defrag volume /v >filename.txt - To interrupt defragmentation, at the command line, press CTRL+C. - Running the defrag command and Disk Defragmenter are mutually exclusive. If using Disk Defragmenter to defragment a volume and running the defrag command at a command-line, the defrag command fails. Conversely, if running the defrag command and open Disk Defragmenter, the defragmentation options in Disk Defragmenter are unavailable.
DEL Deletes one or more files. del [Drive:][Path] FileName [ ...] [/p] [/f] [/s] [/q] [/a[:attributes]] erase [Drive:][Path] FileName [ ...] [/p] [/f] [/s] [/q] [/a[:attributes]] Parameters: - [Drive:][Path] FileName -- Specifies the location and name of the file or set of files to delete. Filename is required. Mmultiple file names can be specified. Separate file names with spaces, commas, or semicolons. - /p -- Prompts for confirmation before deleting the specified file. - /f -- Forces deletion of read-only files. - /s -- Deletes specified files from the current directory and all subdirectories. Displays the names of the files as they are being deleted. - /q -- Specifies quiet mode -- no prompt for delete confirmation is given. - /a -- Deletes files based on specified attributes. - attributes -- Specifies any of the following file attributes: Attribute - Description r - Read-only a - Archive s - System h - Hidden - - Prefix meaning "not" - /? -- Displays help at the command prompt. Remarks: Using /p: ========= If /p is used, del displays the name of a file and sends the following message: filename, Delete (Y/N)? Press Y to confirm the deletion, N to cancel the deletion and display the next file name (if a group of files was specified), or CTRL+C to stop the del command. Disabling command extensions: ============================= If command extensions are disabled, the /s command-line option displays the names of any files that were not found, instead of displaying the names of files that are being deleted (i.e. the behavior is reversed). For more information about disabling command extensions, see cmd in Related Topics. Deleting more than one file at a time: ====================================== To delete all of the files in a folder, type del followed by [Drive:]Path. For example, the following command deletes all files in the \Work folder: del \work Wildcards (i.e. * and ?) can be used to delete more than one file at a time. However, use wildcards cautiously with the del command to avoid deleting files unintentionally. For example, by typing the following command: del *.* The del command displays the following prompt: All files in directory will be deleted! Are you sure (Y/N)? Press Y and then ENTER to delete all files in the current folder, or press N and then ENTER to cancel the deletion. Before using wildcards with the del command to delete a group of files, use the same wildcards with the dir command to see a list of the names of all the files included in the group. Warning: After deleting a file from your disk using del, it cannot be retrieved. The del command, with different parameters, is available from the Recovery Console. Examples: To delete all files in a folder named Test on drive C:\, type either of the following: del c:\test del c:\test\*.*
Desktop Display Settings
This is a short cut to start up the DESKTOP DISPLAY Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
DESK.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Device Manager
This is a short cut to start up the Device Manager dialog.
Either make a shortcut on the desktop with this or do START then RUN then type in
DEVMGMT.MSC and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Defragment Disk
This is a short cut to start up the Defragment Disk dialog.
Either make a shortcut on the desktop with this or do START then RUN then type in
DFRG.MSC and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
DIR Displays a list of a directory's files and subdirectories. dir [Drive:][Path][FileName] [...] [/p] [/q] [/w] [/d] [/a[[:]attributes]] [/o[[:]SortOrder]] [/t[[:]TimeField]] [/s] [/b] [/l] [/n] [/x] [/c] [/4] Parameters: - [Drive:][Path] -- Specifies the drive and directory for which to display a listing. - [FileName] -- Specifies a particular file or group of files for which to display a listing. - /p -- Displays one screen of the listing at a time. To see the next screen, press any key on the keyboard. - /q -- Displays file ownership information. - /w -- Displays the listing in wide format, with as many as five file names or directory names on each line. - /d -- Same as /w but files are sorted by column. - /a [[:] attributes] -- Displays only the names of those directories and files with the attributes specified. If /a is omitted, dir displays the names of all files except hidden and system files. If /a is specified without any attributes, dir displays the names of all files, including hidden and system files. The following list describes each of the values that can be used for attributes. The colon (:) is optional. Use any combination of these values, and do not separate the values with spaces. Value - Description h - Hidden files s - System files d - Directories a - Files ready for archiving r - Read-only files -h - Files that are not hidden -s - Files other than system files -d - Files only (not directories) -a - Files that have not changed since the last backup -r - Files that are not read-only - /o [[:]SortOrder] -- Controls the order in which dir sorts and displays directory names and file names. If /o is omitted, dir displays the names in the order in which they occur in the directory. If /o is specified without SortOrder, dir displays the names of the directories, sorted in alphabetic order, and then displays the names of files, sorted in alphabetic order. The colon (:) is optional. The following list describes each of the values that can be used for SortOrder. Use any combination of the values, and do not separate these values with white spaces. Value - Description n - In alphabetic order by name e - In alphabetic order by extension d - By date and time, earliest first s - By size, smallest first g - With directories grouped before files -n - In reverse alphabetic order by name (Z through A) -e - In reverse alphabetic order by extension (.ZZZ through .AAA) -d - By date and time, latest first -s - By size, largest first -g - With directories grouped after files - /t [[:]TimeField] -- Specifies which time field to display or use for sorting. The following list describes each of the values that can be used for TimeField. Value - Description c - Creation a - Last access w - Last written - /s -- Lists every occurrence, in the specified directory and all subdirectories, of the specified file name. - /b -- Lists each directory name or file name, one per line, including the file name extension. /b does not display heading information or a summary. /b overrides /w. - /l -- Displays unsorted directory names and file names in lowercase. /l does not convert extended characters to lowercase. - /n -- Displays a long list format with file names on the far right of the screen. - /x -- Displays the short names generated for files on NTFS and FAT volumes. The display is the same as the display for /n, but short names are displayed after the long name. - /c -- Displays the thousand separator in file sizes. - /4 -- Displays four-digit year format. - /? -- Displays help at the command prompt. Remarks: Used without parameters, dir displays the disk's volume label and serial number, followed by a list of directories and files on the disk, including their names and the date and time each was last modified. For files, dir displays the name extension and the size in bytes. Dir also displays the total number of files and directories listed, their cumulative size, and the free space (in bytes) remaining on the disk. Using multiple filenames: ========================= Multiple filenames can be used. Separate file names with spaces, commas, or semicolons. Wildcard characters (i.e. ? and *) can be used in FileName to display a group of files. Using wildcards: ================ Wildcards (i.e. ? and *) can be used to display a list of a subset of files and subdirectories. Specifying file display attributes: =================================== If /a is used with more than one value in attributes, dir displays the names of only those files with all the specified attributes. For example, if /a is used with r and -h for attributes by using either /a:r-h or /ar-h, dir displays only the names of read-only files that are not hidden. Specifying file name sorting: ============================= If more than one SortOrder value is specified, dir sorts the file names by the first criterion first, then by the second criterion, and so on. For example, if /o is used with the e and -s values for SortOrder by using either /o:e-s or /oe-s, dir sorts the names of directories and files by extension, with the largest first, and then displays the final result. The alphabetic sorting by extension causes file names with no extensions to appear first, then directory names, and then file names with extensions. Using redirection symbols and pipes: ==================================== When using a redirection symbol (>) to send dir output to a file or a pipe (|) to send dir output to another command, use /a:-d and /b to list the file names only. FileName can be used with /b and /s to specify that dir is to search the current directory and its subdirectories for all file names that match FileName. Dir lists only the drive letter, directory name, file name, and file name extension, one path per line, for each file name it finds. Before using a pipe for redirection, set the TEMP environment variable in the Autoexec.nt file or or in the system variables. Presetting dir parameters: ========================== dir parameters can be preset by including set with the DIRCMD environment variable in the Autoexec.nt file. Any valid combination of dir parameters can be used with set dircmd, i ncluding the location and name of a file. For example, to use the DIRCMD environment variable to set the wide display format (i.e. /w) as the default format, type the following command in the Autoexec.nt file: set dircmd=/w For a single use of the dir command, a parameter can be overridden by using the DIRCMD environment variable. To do so, type the parameter to override at the dir command prompt, preceding the parameter with a minus sign. For example: dir /-w To change the DIRCMD default settings, type: set=NewParameter The new default settings are effective for all subsequent dir commands until set dircmd is used again or until the computer is restarted. To clear all default settings, type: set dircmd= To view the current settings of the DIRCMD environment variable, type: set Set displays a list of environment variables and their settings. For more information about setting environment variables, see Related Topics. The dir command, with different parameters, is available from the Recovery Console. Examples: To display all directories, one after the other, in alphabetical order, in wide format and pausing after each screen, make sure that the root directory is the current directory, and then type: dir /s/w/o/p Dir lists the name of the root directory, the names of the subdirectories of the root directory, and the names of the files in the root directory, including extensions. Then, dir lists the subdirectory names and file names in each subdirectory in the tree. To alter the preceding example so that dir displays the file names and extensions, but omits the directory names, type: dir /s/w/o/p/a:-d To print a directory listing, type: dir > prn When specifing prn, the directory list is sent to the printer attached to the LPT1 port. If the printer is attached to a different port, prn must be replaced with the name of the correct port. Output of the dir command can be redirected to a file by replacing prn with a file name. A path can also be typed. For example, to direct dir output to the file Dir.doc in the Records directory, type: dir > \records\dir.doc If Dir.doc does not exist, dir creates it, unless the Records directory does not exist. In that case, the following message appears: File creation error To display a list of all the file names with the .txt extension in all directories on drive C, type: dir c:\*.txt /w/o/s/p Dir displays, in wide format, an alphabetized list of the matching file names in each directory and pauses each time the screen fills up, until any key is pressed to continue.
DISKCOMP Compare the contents of two floppy disks. diskcomp [drive1: [drive2:]] Parameters: - drive1 -- Specifies the drive containing one of the floppy disks. - drive2 -- Specifies the drive containing the other floppy disk. - /? -- Displays help at the command prompt. Remarks: Used without parameters, diskcomp uses the current drive for both disks to compare. Using disks: ============ The diskcomp command works only with floppy disks. diskcomp cannot be used with a hard disk. If a hard disk drive is specified for drive1 or drive2, diskcomp displays the following error message: Invalid drive specification Specified drive does not exist or is nonremovable Comparing disks: ================ If all tracks on the two disks being compared are the same, diskcomp displays the following message: Compare OK If the tracks are not the same, diskcomp displays a message similar to the following: Compare error on side 1, track 2 When diskcomp completes the comparison, it displays the following message: Compare another diskette (Y/N)? If press Y, diskcomp prompts to insert disks for the next comparison. If press N, diskcomp stops the comparison. When diskcomp makes the comparison, it ignores a disk's volume number. Omitting drive parameters: ========================== If drive2 parameter is omitted, diskcomp uses the current drive for drive2. If both drive parameters are omitted, diskcomp uses the current drive for both. If the current drive is the same as drive1, diskcomp prompts for swapping disks as necessary. Using one drive: ================ If the same floppy disk drive is specified for drive1 and drive2, diskcomp does a comparison by using one drive and prompts for inserting the disks as necessary. The disks might need to be swapped more than once, depending on the capacity of the disks and the amount of available memory. Comparing different types of disks: =================================== Diskcomp cannot compare a single-sided disk with a double-sided disk, nor a high-density disk with a double-density disk. If the disk in drive1 is not of the same type as the disk in drive2, diskcomp displays the following message: Drive types or diskette types not compatible Using diskcomp with networks and redirected drives: =================================================== Diskcomp does not work on a network drive or on a drive created by the subst command. If attempt to use diskcomp with a drive of any of these types, diskcomp displays the following error message: Invalid drive specification Comparing an original disk with a copy: ======================================= When using diskcomp with a disk that was made by using copy, diskcomp might display a message similar to the following: Compare error on side 0, track 0 This type of error can occur even if the files on the disks are identical. Although copy duplicates information, it does not necessarily place it in the same location on the destination disk. For more information about comparing individual files on two disks by using Fc, see Related Topics. Understanding diskcomp exit codes: ================================== The following table lists each exit code and a brief description. Exit code - Description 0 - Disks are the same 1 - Differences were found 3 - Hard error occurred 4 - Initialization error occurred To process exit codes returned by diskcomp, use errorlevel on the if command line in a batch program. Examples: If the computer has only one floppy disk drive (for example, drive A), and two disks are to be compared, type: diskcomp a: a: Diskcomp prompts to insert each disk, as needed. The following example illustrates how to process a diskcomp exit code in a batch program that uses the errorlevel parameter on the if command line: rem Checkout.bat compares the disks in drive A and B echo off diskcomp a: b: if errorlevel 4 goto ini_error if errorlevel 3 goto hard_error if errorlevel 1 goto no_compare if errorlevel 0 goto compare_ok :ini_error echo ERROR: Insufficient memory or command invalid goto exit :hard_error echo ERROR: An irrecoverable error occurred goto exit :break echo "CTRL+C pressed" to stop the comparison goto exit :no_compare echo Disks are not the same goto exit :compare_ok echo The comparison was successful; the disks are the same goto exit :exit
DISKCOPY Copies the contents of one floppy disk to another. diskcopy [drive1: [drive2:]] [/v] Parameters: - drive1 -- Specifies the drive containing the source disk. - drive2 -- Specifies the drive containing the destination disk. - /v -- Verifies that the information is copied correctly. This command-line option slows down the copying process. - /? -- Displays help at the command prompt. Remarks: Used without parameters, diskcopy uses the current drive for the source disk and the destination disk. Using disks: ============ Diskcopy works only with removable disks, such as floppy disks. diskcopy cannot be used with a hard disk. If a hard disk drive is specified for drive1 or drive2, diskcopy displays the following error message: Invalid drive specification Specified drive does not exist or is nonremovable The diskcopy command prompts to insert the source and destination disks and waits for any key on the keyboard to be pressed before continuing. After copying, diskcopy displays the following message: Copy another diskette (Y/N)? If press Y, diskcopy prompts to insert source and destination disks for the next copy operation. To stop the diskcopy process, press N. If copying to an unformatted floppy disk in drive2, diskcopy formats the disk with the same number of sides and sectors per track as are on the disk in drive1. Diskcopy displays the following message while it formats the disk and copies the files: Formatting while copying Disk serial numbers: ==================== If the source disk has a volume serial number, diskcopy creates a new volume serial number for the destination disk and displays the number when the copy operation is complete. Omitting drive parameters: ========================== If the drive2 parameter is omitted, diskcopy uses the current drive as the destination drive. If both drive parameters are omitted, diskcopy uses the current drive for both. If the current drive is the same as drive1, diskcopy prompts to swap disks as necessary. Using one drive for copying: ============================ If drive1 and drive2 are the same, diskcopy prompts to switch disks. If both Drive parameters are omitted and the current disk drive is a floppy disk drive, diskcopy prompts each time a disk needs to be inserted in the drive. If the disks contain more information than available memory can hold, diskcopy cannot read all of the information at once. Diskcopy reads from the source disk, writes to the destination disk, and prompts to insert the source disk again. This process continues until the entire disk has been copied. Avoiding disk fragmentation: ============================ Because diskcopy makes an exact copy of the source disk on the destination disk, any fragmentation on the source disk is transferred to the destination disk. Fragmentation is the presence of small areas of unused disk space between existing files on a disk. A fragmented source disk can slow down the process of finding, reading, or writing files. To avoid transferring fragmentation from one disk to another, use copy or xcopy to copy the disk. Because copy and xcopy copy files sequentially, the new disk is not fragmented. Warning: xcopy cannot be used to copy a startup disk. Understanding diskcopy exit codes: ================================== The following table lists each exit code and a brief description. Exit code - Description 0 - Copy operation was successful 1 - Nonfatal read/write error occurred 3 - Fatal hard error occurred 4 - Initialization error occurred To process exit codes returned by diskcomp, use the errorlevel on the if command line in a batch program. For an example of a batch program that processes exit codes, see diskcomp in Related Topics. Examples:Examples: To copy the disk in drive B to the disk in drive A, type: diskcopy b: a:
Disk Management
This is a short cut to start up the Disk Management dialog. This dialog can tell if
the disk drive is of type NTSF or FAT.
Either make a shortcut on the desktop with this or do START then RUN then type in
DISKMGMT.MSC and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
DOSKEY Calls doskey.exe, which recalls Windows XP commands, edits command lines and creates macros. doskey {/reinstall | /listsize=size | /macros:[{all | exename}] | /history | /insert | /overstrike | /exename=exename | /macrofile=FileName | macroname=[text]} Parameters: - /reinstall -- Installs a new copy of doskey.exe. Clears the command history buffer. - /listsize=size -- Specifies the maximum number of commands in the history buffer. - /macros -- Displays a list of all doskey macros. A redirection symbol (>) can be used with /macros to redirect the list to a file. /macros can be abbreviated to /m. - all -- Displays doskey macros for all executables. - exename -- Displays doskey macros for the specified executable. - /history -- Displays all commands stored in memory. A redirection symbol (>) can be used with /history to redirect the list to a file. /history can be abbreviated as /h. - {/insert | /overstrike} -- Specifies whether new typed text is to replace old text. If /insert is used, new typed text typed on a line is inserted into old text (i.e., as if the INSERT key were pressed). If /overstrike is used, new text replaces old text. The default setting is /overstrike. - /exename=exename -- Specifies the program (i.e., executable) in which the doskey macro runs. - /macrofile=FileName -- Specifies a file containing macros to install. - macroname=[text] -- Creates a macro that carries out the commands specified by text. Macroname specifies the name to assign to the macro. Text specifies the commands to record. If text is left blank, macroname is cleared of any assigned commands. - /? -- Displays help at the command prompt. Remarks: Using doskey.exe: ================= doskey.exe is always available for all character-based, interactive programs (such as program debuggers or file transfer programs), and maintains a command history buffer and macros for each program that it starts. doskey command-line options cannot be used from a program. doskey command-line options must be run before starting a program. Program key assignments override doskey key assignments. Recalling a command: ==================== To recall a command, use any of the following keys after starting doskey.exe. If doskey.exe is used within a program, that program's key assignments take precedence. Key - Description UP ARROW - Recalls the command sed before the one displayed. DOWN ARROW - Recalls the command used after the one displayed. PAGE UP - Recalls the oldest command used in the current session. PAGE DOWN - Recalls the most recent command used. Editing the command line: ========================= With doskey.exe, the current command line can be edited. If doskey.exe is used within a program, that program's key assignments take precedence and some doskey.exe editing keys might not work. The following table lists doskey editing keys and their functions. Key or key combination - Description LEFT ARROW - Moves the insertion point back one character. RIGHT ARROW - Moves the insertion point forward one character. CTRL+LEFT ARROW - Moves the insertion point back one word. CTRL+RIGHT ARROW - Moves the insertion point forward one word. HOME - Moves the insertion point to the beginning of the line. END - Moves the insertion point to the end of the line. ESC - Clears the command from the display. F1 - Copies one character from the same column in the template to the same column in the Command Prompt window. (The template is a memory buffer that holds the last command typed.) F2 - Searches forward in the template for the next key typed after pressing F2. doskey.exe inserts the text from the template up to, but not including, the character specified. F3 - Copies the remainder of the template to the command line. doskey.exe begins copying characters from the position in the template that corresponds to the position indicated by the insertion point on the command line. F4 - Deletes characters from the current insertion point position up to a character specified. To use this editing key, press F4 and type a character. doskey.exe deletes the characters from the current insertion point position to the first letter specified. F5 - Copies the template into the current command line. F6 - Places an end-of-file character (i.e., CTRL+Z) at the current insertion point position. F7 - Displays all commands for this program stored in memory in a pop-up box. Use the UP ARROW key and the DOWN ARROW key to select the command wanted, and press ENTER to run the command. The sequential number noted in front of the command and use this number in conjunction with the F9 key. ALT+F7 - Deletes all commands stored in memory for the current history buffer. F8 - Displays all commands in the history buffer that start with the characters in the current command. F9 - Prompts for a history buffer command number, then displays the command associated with the number specified. Press ENTER to run the command. To display all the numbers and their associated commands, press F7. ALT+F10 - Deletes all macro definitions. Using doskey within a program: ============================== Certain character-based, interactive programs, such as program debuggers or file transfer programs (FTP), automatically use doskey.exe. To use doskey.exe, a program must be a console process and use buffered input. Program key assignments override doskey key assignments. For example, if the program uses the F7 key for some function, then a doskey command history cannot be gotten in a pop-up window. With doskey.exe a command history can be maintained for each program started, repeat and edit previous commands at the program's prompt, and start doskey macros created for the program. If exit then restart a program from the same Command Prompt window, the command history from the previous program session is available. doskey.exe must be run before starting a program. doskey command-line options cannot be used from a program's command prompt, even if the program has a shell command. To customize how doskey.exe works with a program and create doskey macros for that program, first create a batch program that modifies doskey.exe and starts the program. Specifying a default insert mode: ================================= If INSERT key is pressed, then type text on the doskey command line in the middle of old text without replacing the old text. However, after pressing ENTER, doskey.exe returns the keyboard to the replace mode. INSERT must be again to return to return to insert mode. Use /insert to switch the keyboard to insert mode each time ENTER is pressed. The keyboard effectively remains in insert mode until /overstrike is used. To temporarily return to replace mode, press the INSERT key, but after pressing ENTER, doskey.exe returns the keyboard to insert mode. The insertion point changes shape when the INSERT key is used to change from one mode to the other. Creating a macro: ================= doskey.exe can be used to create macros that carry out one or more commands. The following table lists special characters than can be used to control command operations when a macro is defined. Character - Description $G or $g - Redirects output. Use either of these special characters to send output to a device or a file instead of to the screen. This character is equivalent to the redirection symbol for output (>). $G$G or $g$g - Appends output to the end of a file. Use either of these special double characters to append output to an existing file instead of replacing the data in the file. These double characters are equivalent to the append redirection symbol for output (>>). $L or $l - Redirects input. Use either of these special characters to read input from a device or a file instead of from the keyboard. This character is equivalent to the redirection symbol for input (<). $B or $b - Sends macro output to a command. These special characters are equivalent to using the pipe (|) on a command line. $T or $t - Separates commands. Use either of these special characters to separate commands when creating macros or typing commands on the doskey command line. These special characters are equivalent to using the ampersand (&) on a command line. $$ - Specifies the dollar-sign character ($). $1 through $9 - Represent any command-line information to specify when running the macro. The special characters $1 through $9 are batch parameters, which make it possible to use different data on the command line each time the macro is run. The $1 character in a doskey command is similar to the %1 character in a batch program. $* - Represents all the command-line information to specify when typing the macro name. The special character $* is a replaceable parameter that is similar to the batch parameters $1 through $9, with one important difference: everything typed on the command line after the macro name is substituted for the $* in the macro. Running a doskey macro: ======================= To run a macro, type the macro name starting at the first position on the command line. If the macro was defined with $* or any of the batch parameters $1 through $9, use a white space to separate parameters. A doskey macro cannot be run from a batch program. Creating a macro with the same name as a Windows XP command: ============================================================ For a particular command with specific command-line options, a macro can be created that has the same name as the command. To specify whether to run the macro or the command, follow these guidelines: To run the macro, begin typing the macro name immediately after the command prompt, with no space between the prompt and the command name. To run the command, insert one or more white spaces between the command prompt and the command name. Deleting a macro: ================= To delete a macro, type: doskey macroname= Examples: The /macros and /history command-line options are useful for creating batch programs to save macros and commands. For example, to store all current doskey macros, type: doskey /macros > macinit To use the macros stored in Macinit, type: doskey /macrofile=macinit To create a batch program named Tmp.bat that contains recently used commands, type: doskey /history > tmp.bat To define a macro with multiple commands, use $t to separate commands, as follows: doskey tx=cd temp$tdir/w $* In the preceding example, the TX macro changes the current directory to Temp and then displays a directory listing in wide display format. Use $* at the end of the macro to append other command-line options to dir when running TX. The following macro uses a batch parameter for a new directory name: doskey mc=md $1$tcd $1 The macro creates a new directory and then changes to it from the current directory. To use the preceding macro to create and change to a directory named Books, type: mc books To create a doskey macro for a program called Ftp.exe, include /exename as follows: doskey /exename:ftp.exe go=open 10.127.1.100$tmget *.TXT c:\reports$bye To use the preceding macro, start ftp. At the ftp prompt, type: go Ftp runs the open, mget, and bye commands. To create a macro that performs a quick and unconditional format of a disk, type: doskey qf=format $1 /q /u To format a disk in drive A quickly and unconditionally, type: qf a:
DRIVERQUERY Displays a list of all installed device drivers and their properties driverquery [/s Computer][/u Domain\User /p Password][/fo {TABLE|LIST|CSV}][/nh][/v][/si] Parameters: - /s Computer -- Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer. - /u Domain\User -- Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command. - /p Password -- Specifies the password of the user account that is specified in the /u parameter. - /fo {TABLE|LIST|CSV} -- Specifies the format to display the driver information. Valid values are TABLE, LIST, and CSV. The default format for output is TABLE. - /nh -- Omits the header row from the displayed driver information. Valid when the /fo parameter is set to TABLE or CSV. - /v -- Specifies that detailed driver information be displayed. - /si -- Displays digital signature information for both signed and unsigned device drivers. - /? -- Displays help at the command prompt. Examples: - driverquery - driverquery /fo csv - driverquery /nh - driverquery /s ipaddress - driverquery /s server1 /u hirpln /v driverquery /s server1 /u maindom\hirpln /p p@ssw3d /fo list
ECHO Turns the command-echoing feature on or off, or displays a message. echo [{on|off}] [message] Parameters: - {on|off} -- Specifies whether to turn the command-echoing feature on or off. - message -- Specifies text to display on the screen. - /? -- Displays help at the command prompt. Remarks: Used without parameters, echo displays the current echo setting. The echo message command is useful when echo is turned off. To display a message that is several lines long without displaying other commands, include several echo message commands after the echo off command in the batch program. When using echo off, the command prompt does not appear on the screen. To display the command prompt, type echo on. To prevent echoing of a line, insert an at sign (@) in front of a command in a batch program. To echo a blank line on the screen, type: echo. To display a pipe (|) or redirection character (< or >) when using echo, use a caret character immediately before the pipe or redirection character (for example: ^>, ^<, or ^| ). To echo the caret character (^), type two (^^). Examples: The following example is a batch program that includes a three-line message preceded by and then followed by a blank line: - echo off - echo. - echo This batch program - echo formats and checks - echo new disks - echo. To turn echo off without echoing the echo command, type an at sign (@) before the command as follows: @echo off The if and echo commands can be used on the same command line. For example: if exist *.rpt echo The report has arrived
ENDLOCAL Ends localization of environment changes in a batch file, restoring environment variables to their values before the matching setlocal command. Parameters: - /? -- Displays help at the command prompt. Remarks: endlocal can only be used in a script or batch file, endlocal used outside of a script or batch file has no effect. There is an implicit endlocal command at the end of a batch file. Environment changes made after ENDLOCAL has been issued are not local to the batch file; the previous settings are not restored on termination of the batch file. With command extensions enabled (i.e. the default), the endlocal command restores the state of command extensions (i.e. enabled or disabled) to what it was before the matching setlocal command was executed. For more information about enabling and disabling command extensions, see cmd in Related Topics. If Command Extensions are enabled ENDLOCAL changes as follows: If the corresponding SETLOCAL enable or disabled command extensions using the new ENABLEEXTENSIONS or DISABLEEXTENSIONS options, then after the ENDLOCAL, the enabled/disabled state of command extensions will be restored to what it was prior to the matching SETLOCAL command execution. Examples: Environment variables in a batch file can be localized. For example: @echo off rem This program starts the superapp batch program on the network, rem directs the output to a file, and displays the file rem in Notepad. setlocal path=g:\programs\superapp;%path% call superapp>c:\superapp.out endlocal start notepad c:\superapp.out
ERASE
Deletes one or more files.
See DEL
Event Viewer
This is a short cut to start up the Event Viewer dialog.
Either make a shortcut on the desktop with this or do START then RUN then type in
EVENTVWR and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
EXIT Exits the current batch script or the Cmd.exe program (i.e., the command interpreter) and returns to the program that started Cmd.exe or to the Program Manager. exit [/b] [ExitCode] Parameters: - /b -- Exits the current batch script. - ExitCode -- Specifies a numeric number. - /? -- Displays help at the command prompt. Remarks: If /b is used outside of a batch script, it will exit Cmd.exe. If /b is used, Cmd.exe sets the ERRORLEVEL to the specified ExitCode. If you exit Cmd.exe, Cmd.exe sets the process exit code with the specified ExitCode.
Windows Explorer This is a short cut to start up Windows Explorer. Windows Explorer normally displays the dialog and starts at "My Documents" which it opens the first level. To select another point where Explorer starts, type in the following: explorer.exe /e,The given path must be a folder immediately in the root folder. The path can be something such as these examples: C:\myfolder\pictures J:\backups Z: To have Explorer start at the same folder that the command prompt is already at, type in (that last character is a period which means "current directory"): explorer.exe /e, . To have Explorer start at the folder that is one higher up that the folder that is the folder that te command prompt is already at, type in (those last two characters are periods which means "parent directory of the current directory"): explorer.exe /e, .. Either make a shortcut on the desktop with this or do START then RUN then type in EXPLORER and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
FILTERS
Used in conjunction with the command redirection pipe character (|), a command filter
is a command within a command that reads the command's input, transforms the input,
and then writes the output. Filter commands help sort, view, and select parts of
a command output. Filter commands divide, rearrange, or extract portions of the
information that passes through them. The following table lists filter commands that
are available in Windows XP.
The three filters are:
- more -- Displays the contents of a file or the output of a command in one Command
Prompt window at a time.
- find -- Searches through files and command output for the characters specified.
- sort -- Alphabetizes files and command output.
To send input from a file to a filter command, use a less than sign (<). Use a pipe (|)
to get input from another command
more:
=====
Displays the contents of a file or the output of a command in one Command Prompt window
at a time. For example, to display the contents of a file called List.txt in one Command
Prompt window at a time, type:
more < list.txt
One Command Prompt window of information appears, and then the -- More -- prompt appears
at the bottom of the Command Prompt window. To continue to the next Command Prompt window,
press any key on the keyboard except PAUSE. To stop the command without viewing more
information, press CTRL+C.
Use the more command when working with a command that produces more than one Command
Prompt window of output. For example, to view a directory tree on the hard disk. If
there are more directories than can be displayed in the Command Prompt window, use the
tree command with a pipe (|) and the more command as follows:
tree c:\ | more
The first Command Prompt window of output from the tree command appears, followed by
the -- More -- prompt. Output pauses until any key, except PAUSE, is pressed
find:
=====
Searches files for the given string or text. Cmd.exe displays every line that matches
the given string or text in the Command Prompt window. Use the find command either as
a filter command or a standard Windows XP command. For more information about using
find as a standard command, see Find.
To use find as a filter command, include a less than sign (<) then the string or text
to be searched. By default, find searches are case-sensitive. For example, the following
command finds occurrences of the string "Pacific Rim" in the file Trade.txt:
find "Pacific Rim" < trade.txt
The output does not include any occurrences of "pacific rim." It includes occurrences
of the capitalized "Pacific Rim" only.
To save the output of the find command rather than display it in the Command Prompt
window, type a greater than sign (>) and the name of the file in which to store the
output. For example, the following command finds occurrences of "Pacific Rim" in
the Trade.txt file and saves them in Nwtrade.txt:
find "Pacific Rim" < trade.txt > nwtrade.txt
sort:
=====
Alphabetize a text file or the output of a command. For example, the following sorts the
contents of a file named List.txt and displays the results in the Command Prompt window:
sort < list.txt
In this example, the sort command sorts the lines of the List.txt file into an alphabetical
list and displays the results without changing the file. To save the output of the sort
command rather than display it, type a greater than sign (>) and a file name. For example,
the following command alphabetizes the lines of the List.txt file and stores the results
in the Alphlist.txt file:
sort < list.txt > alphlist.txt
To sort the output of a command, type the command, type a pipe (|), and then type sort
(i.e. command | sort). For example, the following command sorts the lines that include
the string "Jones" (i.e. the find command output) in alphabetical order:
find "Jones" maillst.txt | sort
FC fc [/a] [/b] [/c] [/l] [/lbn] [/n] [/t] [/u] [/w] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2 Parameters: - /a -- Abbreviates the output of an ASCII comparison. Instead of displaying all of the lines that are different, fc displays only the first and last line for each set of differences. - /b -- Compares the files in binary mode. Fc compares the two files byte by byte and does not attempt to resynchronize the files after finding a mismatch. This is the default mode for comparing files that have the following file extensions: .exe, .com, .sys, .obj, .lib, or .bin. - /c -- Ignores the case of letters. - /l -- Compares the files in ASCII mode. Fc compares the two files line by line and attempts to resynchronize the files after finding a mismatch. This is the default mode for comparing files, except files with the following file extensions: .exe, .com, .sys, .obj, .lib, or .bin. - /lbn -- Sets the n number of lines for the internal line buffer. The default length of the line buffer is 100 lines. If the files being compared have more than this number of consecutive differing lines, fc cancels the comparison. - /n -- Displays the line numbers during an ASCII comparison. - /t -- Prevents fc from converting tabs to spaces. The default behavior is to treat tabs as spaces, with stops at each eighth character position. - /u -- Compares files as Unicode text files. - /w -- Compresses white space (i.e., tabs and spaces) during the comparison. If a line contains many consecutive spaces or tabs, /w treats these characters as a single space. When used with the /w command-line option, fc ignores (and does not compare) white space at the beginning and end of a line. - /nnnn -- Specifies the number of consecutive lines that must match before fc considers the files to be resynchronized. If the number of matching lines in the files is less than nnnn, fc displays the matching lines as differences. The default value is 2. - [drive1:][path1]filename1 -- Specifies the location and name of the first file to compare. Filename1 is required. - [drive2:][path2]filename2 -- Specifies the location and name of the second file to compare. Filename2 is required. - /? -- Displays help at the command prompt. Remarks: Reporting differences between files for an ASCII comparison When using fc for an ASCII comparison, fc displays differences between two files in the following order: Name of the first file Lines from filename1 that differ between the files First line to match in both files Name of the second file Lines from filename2 that differ First line to match Using /b for binary comparisons: ================================ /b displays mismatches found during a binary comparison as follows: xxxxxxxx: yy zz The value of xxxxxxxx specifies the relative hexadecimal address for the pair of bytes, measured from the beginning of the file. Addresses start at 00000000. The hexadecimal values for yy and zz represent the mismatched bytes from filename1 and filename2, respectively. Using wildcards: ================ Wildcards (i.e., * and ?) can be used in filename1 and filename2. If wildcards are used in filename1, fc compares all the specified files to the file specified by FileName. If wildcards are used in filename2, fc uses the corresponding value from filename1. Working with memory: ==================== When comparing ASCII files, fc uses an internal buffer (large enough to hold 100 lines) as storage. If the files are larger than the buffer, fc compares what it can load into the buffer. If fc does not find a match in the loaded portions of the files, it stops and displays the following message: Resynch failed. Files are too different. When comparing binary files that are larger than available memory, fc compares both files completely, overlaying the portions in memory with the next portions from the disk. The output is the same as that for files that fit completely in memory. Examples: To make an ASCII comparison of two text files that are named Monthly.rpt and Sales.rpt and display the results in abbreviated format, type: fc /a monthly.rpt sales.rpt To make a binary comparison of two batch files named Profits.bat and Earnings.bat, type: fc /b profits.bat earnings.bat The results similar to the following appear: 00000002: 72 43 00000004: 65 3A 0000000E: 56 92 00000012: 6D 5C 00000013: 0D 7C 00000014: 0D 0A 00000015: 0A 0D 0000001E: 43 7A 0000001F: 09 0A 00000022: 72 44 ... ... ... 000005E0: 00 61 000005E1: 00 73 000005E2: 00 73 000005E3: 00 69 000005E4: 00 67 000005E5: 00 6E 000005E6: 00 6D 000005E7: 00 65 000005E8: 00 6E FC: Earnings.bat longer than Profits.bat If the Profits.bat and Earnings.bat files are identical, fc displays the following message: fc: no differences encountered To compare every .bat file in the current directory with the file New.bat, type: fc *.bat new.bat To compare the file New.bat on drive C with the file New.bat on drive D, type: fc c:new.bat d:*.bat To compare each batch file in the root directory on drive C to the file with the same name in the root directory on drive D, type: fc c:*.bat d:*.bat
FIND Searches for a specific string of text in a file or files. find [/v] [/c] [/n] [/i] "string" [[Drive:][Path]FileName[...]] Parameters: - /v -- Displays all lines that do not contain the specified string. - /c -- Counts the lines that contain the specified string and displays the total. - /n -- Precedes each line with the file's line number. - /i -- Specifies that the search is not case-sensitive. - "string" -- Required. Specifies the group of characters to search for. The string must be enclosed in quotation marks (i.e., "string"). - [Drive:][Path] FileName -- Specifies the location and name of the file in which to search for the specified string. - /? -- Displays help at the command prompt. Remarks: After searching the specified file or files, find displays any lines of text that contain the specified string. Specifying a string: ==================== If /i is not used, find searches for exactly what is specified for string. For example, the find command treats the characters "a" and "A" differently. If /i is used, however, find is not case-sensitive and treats "a" and "A" as the same character. If the string to search for contains quotation marks, two quotation marks must be used for each quotation mark contained within the string (i.e., "StringContaining""QuotationMarks"). Using find as a filter: ======================= If a file name is omitted, find acts as a filter, taking input from the standard input source (usually the keyboard, a pipe, or a redirected file) and then displaying any lines that contain string. Ordering command syntax: ======================== Parameters and command-line options for the find command can be in any order. Using wildcards: ================ Wildcards (i.e., * and ?) cannot be used in file names or extensions that are specified with the find command. To search for a string in a set of files that are specified with wildcards, the find command can be used in a 'for' command. Using /v or /n with /c: ======================= If /c and /v are used in the same command line, find displays a count of the lines that do not contain the specified string. If /c and /n are specified in the same command line, find ignores /n. Using find with carriage returns: ================================= The find command does not recognize carriage returns. When searching for text in a file that includes carriage returns, the search string must be limited to text that can be found between carriage returns (i.e., a string that is not likely to be interrupted by a carriage return). For example, find does not report a match for the string "tax file" wherever a carriage return occurs between the word "tax" and the word "file." Examples: To display all lines from Pencil.ad that contain the string "Pencil Sharpener", type: find "Pencil Sharpener" pencil.ad To find a string that contains text within quotation marks, first enclose the entire string in quotation marks. Second, use two quotation marks for each quotation mark contained within the string. To find "The scientists labeled their paper "for discussion only." It is not a final report." in Report.doc, type: find "The scientists labeled their paper ""for discussion only."" It is not a final report." report.doc To search for a set of files, use the find command with the 'for' command. To search the current directory for files that have the extension .bat and that contain the string "PROMPT," type: for %f in (*.bat) do find "PROMPT" %f To search the hard disk to find and display the file names on drive C that contain the string "CPU," use the pipe (|) to direct the results of a dir command to find as follows: dir c:\ /s /b | find "CPU" Because find searches are case-sensitive and dir produces uppercase output, either type the string "CPU" in uppercase letters or use the /i command-line option with find.
FINDSTR Searches for strings in files. findstr [/b] [/e] [/l] [/r] [/s] [/i] [/x] [/v] [/n] [/m] [/o] [/p] [/offline] [/g:file] [/f:file] [/c:string] [/d:dirlist] [/a:ColorAttribute] [strings] [[Drive:][Path] FileName [...]] Parameters: - /b -- Matches the pattern if at the beginning of a line. - /e -- Matches the pattern if at the end of a line. - /l -- Uses search strings literally. - /r -- Uses search strings as regular expressions. Findstr interprets all metacharacters as regular expressions unless /l is used. - /s -- Searches for matching files in the current directory and all subdirectories. - /i -- Specifies that the search is not to be 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 line that matches. - /m -- Prints only the file name if a file contains a match. - /o -- Prints seek offset before each matching line. - /p -- Skips files with non-printable characters. - /offline -- Processes files with offline attribute set. - /f:file -- Reads file list from the specified file. - /c:string -- Uses specified text as a literal search string. - /g:file -- Gets search strings from the specified file. - /d:dirlist -- Searches a comma-delimited list of directories. - /a:ColorAttribute -- Specifies color attributes with two hexadecimal digits. - strings -- Specified text to be searched for in FileName. - [Drive:][Path] FileName [...] -- Specifies a file or files to search. - /? -- Displays help at the command prompt. Remarks: Using regular expressions with findstr Findstr is capable of finding, in any ASCII files, the exact specified text. However, sometimes only partial information can be searcheed. In such cases, findstr has the powerful capability to search for patterns of text using regular expressions. Regular expressions are a notation for specifying patterns of text, as opposed to exact strings of characters. The notation uses literal characters and metacharacters. Every character that does not have special meaning in the regular expression syntax is a literal character and matches an occurrence of that character. For example, letters and numbers are literal characters. A metacharacter is a symbol with special meaning (an operator or delimiter) in the regular-expression syntax. The following table lists the metacharacters that findstr accepts. Character - Value . - Wildcard: any character * - Repeat: zero or more occurrences of previous character or class ^ - Line position: beginning of line $ - Line position: end of line [class] - Character class: any one character in set [^class] - Inverse class: any one character not in set [x-y] - Range: any characters within the specified range \x - Escape: literal use of metacharacter x \- Word position: end of word The special characters in regular expression syntax are most powerful when used together. For example, the following combination of the wildcard character (.) and repeat (*) character match any string of characters: .* Use the following expression as part of a larger expression that matches any string beginning with "b" and ending with "ing": b.*ing Examples: Use spaces to separate multiple search strings unless the argument is prefixed with /c. To search for "hello" or "there" in file x.y, type: findstr "hello there" x.y To search for "hello there" in file x.y, type: findstr /c:"hello there" x.y To find all occurrences of the word "Windows" (with an initial capital W) in the file Proposal.txt, type the following: findstr Windows proposal.txt To search every file in the current directory and all subdirectories that contained the word Windows, regardless of the letter case, type the following: findstr /s /i Windows *.* To find all occurrences of lines that contain the word "FOR", preceded by any number of spaces, (as in a computer program loop), and to include the line number where each occurrence is found, type the following: findstr /b /n /c:" *FOR" *.bas To search for several different items in the same set of files, create a text file that contains each search criterion on a new line. The exact files to search can be specified. To use the search criteria in the file Finddata.txt, search the files listed in Filelist.txt, and then store the results in the file Results.out, type the following: findstr /g:finddata.txt /f:filelist.txt > results.out To find the word 'computer' in every file in the current directory and all subdirectories, regardless of the letter case, type the following: findstr /s /i /m "\ " *.* To find all words that begin with the letters 'comp', such as 'computer' and 'compliment' and 'compete', type the following: findstr /s /i /m "\
Firewall Settings This is a short cut to start up the Firewall Settings dialog. Either make a shortcut on the desktop with this or do START then RUN then type in FIREWALL.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
FOR Runs a specified command for each file in a set of files. This can be run either in a batch file or at a command prompt. for {%variable|%%variable} in (set) do command [ CommandLineOptions] Parameters: - {%variable|%%variable} -- Required. Represents a replaceable parameter. Use %variable to carry out for from the command prompt. Use %%variable to carry out the for command within a batch file. Variables are case-sensitive and must be represented with an alpha value, such as %A, %B or %C. - (set) -- Required. Specifies one or more files, directories, range of values or text strings to process with the specified command. The parentheses are required. - command -- Required. Specifies the command to carry out on each file, directory, range of values, or text string included in the specified (set). - CommandLineOptions -- Specifies any command-line options to use with the specified command. - /? -- Displays help at the command prompt. Remarks: To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, thus %i is different from %I. The following attributes apply to the for command: - The for command replaces %variable or %%variable with each text string in the specified set until the command processes all of the files. - For variable names are case-sensitive, global, and no more than 52 total can be active at any one time. - To avoid confusion with the batch parameters %0 through %9, use any character for variable except the numerals 0 through 9. For simple batch files, a single character such as %%f works. - Multiple values for variable can be used in complex batch files to distinguish different replaceable variables. Specifying a group of files: ============================ The set parameter can represent a single group of files or several groups of files. Wildcards (* and ?) can be used to specify a file set. The following are valid file sets: - (*.doc) - (*.doc *.txt *.me) - (jan*.doc jan*.rpt feb*.doc feb*.rpt) - (ar??1991.* ap??1991.*) The first value in set replaces %variable or %%variable, and then the specified command processes this value. This continues until all of the files (or groups of files) that correspond to the set value are processed. Using the in and do keywords: ============================= In and do are not parameters, but they must be used with for. If either words are omitted, an error message appears. Using additional forms of for: ============================== If command extensions are enabled (i.e. the default), the following additional forms of for are supported: Directories only: ----------------- If set contains wildcards (* and ?), the specified command executes for each directory (instead of a set of files in a specified directory) that matches set. The syntax is: for /D {%% | %}variable in (set) do command [CommandLineOptions] Recursive: ---------- Walks the directory tree rooted at [Drive:]Path, executing the for statement in each directory of the tree. If no directory is specified after /R, the current directory is assumed. If set is just a single period (.), it only enumerates the directory tree. The syntax is: for /R [[Drive :]Path] {%% | %}variable in (set) do command [CommandLineOptions] Iterating a range of values: ---------------------------- Use an iterative variable to set the starting value (start#) and then step through a set range of values until the value exceeds the set ending value (end#). /L will execute the iterative by comparing start# with end#. If start# is less than end# the command will execute. When the iterative variable exceeds end# the command shell exists the loop. A negative step# can be used to step through a range in decreasing values. For example, (1,1,5) generates the sequence 1 2 3 4 5 and (5,-1,1) generates the sequence (5 4 3 2 1). The syntax is: for /L {%% | %}variable in (start#,step#,end#) do command [CommandLineOptions] Iterating and file parsing: --------------------------- Use file parsing to process command output, strings and file content. Use iterative variables to define the content or strings to examine and use the various ParsingKeywords options to further modify the parsing. Use the ParsingKeywords token option to specify which tokens should be passed as iterator variables. Note that when used without the token option, /F will only examine the first token. File parsing consists of reading the output, string or file content, breaking it up into individual lines of text and then parsing each line into zero or more tokens. The for loop is then called with the iterator variable value set to the token. By default, /F passes the first blank separated token from each line of each file. Blank lines are skipped. The different syntaxes are: for /F ["ParsingKeywords"] {%% | %}variable in (filenameset) do command [CommandLineOptions] for /F ["ParsingKeywords"] {%% | %}variable in ("LiteralString") do command [CommandLineOptions] for /F ["ParsingKeywords"] {%% | %}variable in ('command') do command [CommandLineOptions] The filenameset argument specifies one or more file names. Each file is opened, read and processed before going on to the next file in filenameset. To override the default parsing behavior, specify "ParsingKeywords". This is a quoted string that contains one or more keywords to specify different parsing options. When using the usebackq option, use one of the following syntaxes: for /F ["usebackqParsingKeywords"] {%% | %}variable in ("filenameset") do command [CommandLineOptions] for /F ["usebackqParsingKeywords"] {%% | %}variable in ('LiteralString') do command [CommandLineOptions] for /F ["usebackqParsingKeywords"] {%% | %}variable in (`command`) do command [CommandLineOptions] The following table lists the parsing keywords for ParsingKeywords - Keyword - Description - eol=c - Specifies an end of line character (just one character). - skip=n - Specifies the number of lines to skip 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 to be passed to the for body for each iteration. As a result, additional variable names are allocated. The m-n form is a range, specifying the mth through the nth tokens. If the last character in the tokens= string is an asterisk (*), an additional variable is allocated and receives the remaining text on the line after the last token that is parsed. - usebackq - Specifies that quotation marks can be used to quote file names in filenameset, a back quoted string is executed as a command, and a single quoted string is a literal string command. An example: ----------- FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k This would parse each line in myfile.txt, ignoring lines that begin with a semicolon, passing the 2nd and 3rd token from each line to the for body, with tokens delimited by commas and/or spaces. Notice the for body statements reference %i to get the 2nd token, %j to get the third token, and %k to get all remaining tokens after the third. For file names that contain spaces, quote the file names with double quotes. In order to use double quotes in this manner, use the usebackq option, otherwise the double quotes will be interpreted as defining a literal string to parse. %i is explicitly declared in the for statement and the %j and %k are implicitly declared via the tokens= option. Up to 26 tokens can be used via the tokens= line, provided it does not cause an attempt to declare a variable higher than the letter 'z' or 'Z'. Remember, FOR variables are single-letter, case sensitive, global, with a maximum of 52 total active variables at any one time. Also available is the FOR /F parsing logic on an immediate string, by making the file nameset between the parenthesis a quoted string, using single quote characters. It will be treated as a single line of input from a file and parsed. Finally, the FOR /F command to parse the output of a command is available. Make the file nameset between the parenthesis a back quoted string. It will be treated as a command line, which is passed to a child CMD.EXE and the output is captured into memory and parsed as if it was a file. So the following example: FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i would enumerate the environment variable names in the current environment. Variable substitution: ---------------------- Substitution modifiers for for variable references have been enhanced. The following table lists optional syntax (for any variable I). Variable with modifier - Description %~I - Expands %I which removes any surrounding quotation marks (""). %~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 - Expands path to contain short names only. %~aI - Expands %I to the file attributes of file. %~tI - Expands %I to the date and time of file. %~zI - Expands %I to the size of file. %~$PATH:I - Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string. The following table lists modifier combinations to get compound results. Variable with combined modifiers - Description %~dpI - Expands %I to a drive letter and path only. %~nxI - Expands %I to a file name and extension only. %~fsI - Expands %I to a full path name with short names only. %~dp$PATH:I - Searches the directories listed in the PATH environment variable for %I and expands to the drive letter and path of the first one found. %~ftzaI - Expands %I to an output line that is like dir. In the above examples, optionally replace %I and PATH by other valid values. A valid for variable name terminates the %~ syntax. By using uppercase variable names such as %I, the code is more readable and avoids confusion with the modifiers, which are not case-sensitive. Parsing a string: ----------------- Use the for /F parsing logic on an immediate string by wrapping the filenameset between the parentheses in single quotation marks (i.e. 'filenameset'). Filenameset is treated as a single line of input from a file, and then it is parsed. Parsing output: --------------- /F can be used to parse the output of a command by making the filenameset between the parenthesis a back quoted string. It is treated as a command line, which is passed to a child Cmd.exe and the output is captured into memory and parsed as if it were a file. Examples: To use for in a batch file, use the following syntax: for %%variable in (set) do command [CommandLineOptions] To display the contents of all the files in the current directory that have the extension .doc or .txt using the replaceable variable %f, type: for %f in (*.doc *.txt) do type %f In the preceding example, each file that has the .doc or .txt extension in the current directory is substituted for the %f variable until the contents of every file are displayed. To use this command in a batch file, replace every occurrence of %f with %%f. Otherwise, the variable is ignored and an error message is displayed. To parse a file, ignoring commented lines, type: for /F "eol=; tokens=2,3* delims=," %i in (myfile.txt) do @echo %i %j %k This command parses each line in Myfile.txt, ignoring lines that begin with a semicolon and passing the second and third token from each line to the FOR body (tokens are delimited by commas or spaces). The body of the FOR statement references %i to get the second token, %j to get the third token, and %k to get all of the remaining tokens. If the file names contains spaces, use quotation marks around the text (for example, "File Name"). To use quotation marks, use usebackq. Otherwise, the quotation marks are interpreted as defining a literal string to parse. %i is explicitly declared in the FOR statement, and %j and %k are implicitly declared by using tokens=. Up to 26 tokens using tokens= can be used, provided that it does not cause an attempt to declare a variable higher than the letter 'z' or 'Z'. To parse the output of a command by placing filenameset between the parentheses, type: for /F "usebackq delims==" %i IN (`set`) DO @echo %i This example enumerates the environment variable names in the current environment.
FORMAT Formats a disk for use with Windows XP. format volume [/fs:file-system] [/v:label] [/q] [/a:UnitSize] [/c] [/x] format volume [/v:label] [/q] [/f:size] format volume [/v:label] [/q] [/t:tracks /n:sectors] format volume [/v:label] [/q] format volume [/q] Parameters: - volume -- Specifies the mount point, volume name, or drive letter of the drive to format. If no command-line options are given, format uses the volume type to determine the default format for the disk. - /fs:file-system -- Specifies the file system to use FAT, FAT32, or NTFS Floppy disks can use only the FAT file system. - /v:label -- Specifies the volume label. If /v command-line option is omitted or it is used without specifying a volume label, format prompts for the volume label after the formatting is completed. Use the syntax /v: to prevent the prompt for a volume label. If more than one disk is formatted by using one format command, all of the disks will be given the same volume label. For more information about disk volume labels, click Dir, Label, and Vol in the Related Topics list. - /a:UnitSize -- Specifies the allocation unit size to use on FAT, FAT32, or NTFS volumes. If UnitSize is not specified, it is chosen based on volume size. The following table lists valid values for UnitSize. Value - Description 512 - Creates 512 bytes per cluster. 1024 - Creates 1024 bytes per cluster. 2048 - Creates 2048 bytes per cluster. 4096 - Creates 4096 bytes per cluster. 8192 - Creates 8192 bytes per cluster. 16K - Creates 16 kilobytes per cluster. 32K - Creates 32 kilobytes per cluster. 64K - Creates 64 kilobytes per cluster. - /f:size -- Specifies the size of the floppy disk to format. When possible, use this command-line option instead of the /t and /n command-line options. Windows accepts the following value for size: 1440 or 1440k or 1440kb or 1.44 or 1.44m or 1.44mb 1.44-MB, double-sided, quadruple-density, 3.5-inch disk - /q -- Performs a quick format. Deletes the file table and the root directory of a previously formatted volume but does not perform a sector by sector scan for bad areas. The /q command-line option should be used to format only previously formatted volumes that are known to be in good condition. - /t:tracks -- Specifies the number of tracks on the disk. When possible, use the /f command-line option instead of this command-line option. If the /t command-line option is used, the /n command-line option must also be used. These two command-line options provide an alternative method of specifying the size of the disk being formatted. The /f command-line option cannot be used with the /t command-line option. - /n:sectors -- Specifies the number of sectors per track. When possible, use the /f command-line option instead of this command-line option. If the /n command-line option is used, the /t command-line option must also be used. These two command-line options provide an alternative method of specifying the size of the disk being formatted. The /f command-line option cannot be used with the /n command-line option. - /c -- NTFS only. Files created on the new volume will be compressed by default. - /x -- Causes the volume to dismount, if necessary, before it is formatted. Any open handles to the volume will no longer be valid. - /? -- Displays help at the command prompt. Remarks: Using format at the Recovery Console: ===================================== The format command, with different parameters, is available from the Recovery Console. Administrative privileges: ========================== Only a member of the Administrators group can format a hard drive. Using format : ============= The format command creates a new root directory and file system for the disk. It can also check for bad areas on the disk, and it can delete all data on the disk. To be able to use a new disk, this command must first be used to format the disk. Typing a volume label: ====================== After formatting a floppy disk, format displays the following message: Volume label (11 characters, ENTER for none)? The volume label can be a maximum of 11 characters (including spaces). If no volume label is desired, just press ENTER. For information about volume labels, click label in the Related Topics list. Formatting a hard disk ======================= When formatting a hard disk, format displays a message of the following form before attempting to format the hard disk: WARNING, ALL DATA ON nonremovable DISK DRIVE x: WILL BE LOST! Proceed with Format (Y/N)?_ To format the hard disk, press Y. To not format the hard disk, press N. Administrator rights are required to format a hard disk. Unit size: ========== FAT file systems restrict the number of clusters to no more than 65526. FAT32 file systems restrict the number of clusters to between 65527 and 4177917. NTFS compression is not supported for allocation unit sizes above 4096. Format messages: ================ When formatting is complete, format displays messages showing the total disk space, any space marked as defective, and the space available for the files. Quick formatting: ================= The formatting process can be sped up by using the /q command-line option. Use this command-line option only if there are no bad sectors on the hard disk. Using format with a reassigned drive or a network drive: ======================================================== The format command should not be used on a drive prepared by using the subst command. Disks cannot be formatted over a network. Format exit codes: ================== The following table lists each exit code and a brief description of its meaning. Exit code - Description 0 - The format operation was successful. 1 - Incorrect parameters were supplied. 4 - A fatal error occurred (any error other than 0, 1, or 5). 5 - The user pressed N in response to the prompt "Proceed with Format (Y/N)?" to stop the process. These exit codes can be checked by using the errorlevel condition with the if batch command. Examples: To format a new floppy disk in drive A using the default size, type: format a: To perform a quick format operation on a previously formatted disk in drive A, type: format a: /q To format a floppy disk in drive A and assign it the volume label "DATA," type: format a: /v:DATA
Shared Folder This is a short cut to start up the Shared Folder dialog. Either make a shortcut on the desktop with this or do START then RUN then type in DSMGMT.MSC and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
FTP Transfers files to and from a computer running a File Transfer Protocol (FTP) server service such as Internet Information Services. ftp [-v] [-d] [-i] [-n] [-g] [-s:FileName] [-a] [-w:WindowSize] [-A] [Host] Parameters: - -v -- Suppresses the display of FTP server responses. - -d -- Enables debugging, displaying all commands passed between the FTP client and FTP server. - -i -- Disables interactive prompting during multiple file transfers. - -n -- Suppresses the ability to log on automatically when the initial connection is made. - -g -- Disables file name globbing. Glob permits the use of the asterisk (*) and question mark (?) as wildcard characters in local file and path names. For more information, see Ftp: Glob - -s:FileName -- Specifies a text file that contains ftp commands. These commands run automatically after ftp starts. This parameter allows no spaces. Use this parameter instead of redirection (<). - -a -- Specifies that any local interface can be used when binding the FTP data connection. - -w:WindowSize -- Specifies the size of the transfer buffer. The default window size is 4096 bytes. - -A -- Logs onto the FTP server as anonymous. - Host -- Specifies the computer name, IP address, or IPv6 address of the FTP server to which to connect. The host name or address, if specified, must be the last parameter on the line. - /? -- Displays help at the command prompt. Remarks: Ftp can be used interactively or in batch mode by processing ASCII text files. ftp parameters MUST be prefixed with a hyphen (-) rather than a slash (/). Ftp command-line parameters are case-sensitive. This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections Ftp can be used interactively. After it is started, ftp creates a subenvironment in which ftp commands can be used. To return to the command prompt, type the quit command. When the ftp subenvironment is running, it is indicated by the ftp > command prompt. For more information about ftp subcommands, see Related Topics. Ftp supports the use of IPv6 when the IPv6 protocol is installed. For more information, see IP version 6 and IPv6 applications Examples: To log on to the FTP server named ftp.example.microsoft.com, type the following command: ftp ftp.example.microsoft.com To anonymously log on to the FTP server named ftp.example.microsoft.com, type the following command: ftp -A ftp.example.microsoft.com To log on to the FTP server named ftp.example.microsoft.com and run the ftp commands contained in a file named Resynch.txt, type the following command: ftp -s:resynch.txt ftp.example.microsoft.com
FTYPE Displays or modifies file types used in file name extension associations. Ftype [FileType[=[OpenCommandString]]] Parameters: - FileType -- Specifies the file type to display or change. - OpenCommandString -- Specifies the open command to use when opening files of this type. - /? -- Displays help at the command prompt. Remarks: Used without parameters, ftype displays the file types that have open command strings defined. Within an OpenCommandString, ftype substitutes the following variables: - %0 or %1 are replaced with the file name to open. - %* is replaced with all of the parameters. - %~n is replaced with all of the remaining parameters, starting with the nth parameter, where n can be any number from 2 to 9. - %2 is replaced with the first parameter, %3 with the second, and so on. Examples: To display the current file types that have open command strings defined, type: ftype To display the current open command string for a specific file type, type: ftype FileType To delete the open command string for a specific file type, type: ftype FileType= Type: ASSOC .pl=PerlScript FTYPE PerlScript=perl.exe %1 %* To invoke the Perl script, then type: script.pl 1 2 3 To eliminate the need to type the extensions, type: set PATHEXT=.pl;%PATHEXT% To invoke the Perl script, type: script 1 2 3
GETMAC This is a short cut to display the mac address(es) of your network adapter(s). Either make a shortcut on the desktop with this or do START then RUN then type in GETMAC and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
GOTO Within a batch program, directs Windows XP to a line identified by a label. goto label Parameters: - label -- Specifies the line in a batch program to go to. - /? -- Displays help at the command prompt. Remarks: When the label is found, it processes the commands that begin on the next line. Working with command extensions: ================================ If command extensions are enabled (i.e., the default) and the goto command is specified with a target label of :EOF, control is transfered to the end of the current batch script file and exit the batch script file without defining a label. When goto with the :EOF label is used, a colon must be inserted before the label. For example: goto :EOF For a description of extensions to the call command that make this feature useful, see cmd in Related Topics. Using valid label values: ========================= The label parameter can have spaces but no other separators (ex. semicolons or equal signs). The goto command uses only the first eight characters of a label. For example, the following labels are equivalent and resolve to :hithere0: :hithere0 :hithere01 :hithere02 Matching label with the label in the batch program: =================================================== The label value specified must match a label in the batch program. The label within the batch program must begin with a colon (:). Windows XP recognizes a batch program line beginning with a colon (:) as a label and does not process it as a command. If a line begins with a colon, any commands on that line are ignored. If the batch program does not contain the label specified, the batch program stops and displays the following message: Label not found Using goto for conditional operations: ====================================== goto can be used with other commands to perform conditional operations. For more information about using goto for conditional operations, see if in Related Topics. Examples: The following batch program formats a disk in drive A as a system disk. If the operation is successful, the goto command directs Windows XP to the :end label: echo off format a: /s if not errorlevel 1 goto end echo An error occurred during formatting. :end
GRAFTABL Enables the ability to display an extended character set in graphics mode. graftabl [xxx] [/status] Parameters: - xxx -- Specifies the code page for which the appearance of extended characters in graphics mode is to be defined. The following table lists each valid code page identification number and its Country/Region or language. Value - Country/Region 437 - United States 850 - Multilingual (Latin I) 852 - Slavic (Latin II) 855 - Cyrillic (Russian) 857 - Turkish 860 - Portuguese 861 - Icelandic 863 - Canadian-French 865 - Nordic 866 - Russian 869 - Modern Greek - /status -- Identifies the code page that graftabl is using. - /? -- Displays help at the command prompt. Remarks: For information about using code pages, see chcp or mode (set device code pages) in Related Topics. Graftabl does not change the console input code page. Graftabl affects only the monitor display of extended characters of the code page specified. To change the code page being used, use the mode or chcp command. Understanding graftabl exit codes: ================================== The following table lists each exit code and a brief description of it. Exit code - Description 0 - Character set was loaded successfully. No previous code page was loaded. 1 - An incorrect parameter was specified. No action was taken. 2 - A file error occurred. The errorlevel parameter can be used on the if command line in a batch program to process exit codes returned by graftabl. Examples: To load the graphics character set for code page 437 (United States) into memory, type: graftabl 437 To load the graphics character set for code page 850 (multilingual) into memory, type: graftabl 850
HELP Provides help information for Windows XP commands. HELP [command] Parameters: command - displays help information on that command.
IF Performs conditional processing in batch programs. if [not] errorlevel number command [else expression] if [not] string1==string2 command [else expression] if [not] exist FileName command [else expression] If command extensions are enabled, use the following syntax: if [/i] string1 CompareOp string2 command [else expression] if cmdextversion number command [else expression] if defined variable command [else expression] Parameters: - NOT -- Specifies that the command should be carried out only if the condition is false. - ERRORLEVEL number -- Specifies a true condition only if the previous program run by Cmd.exe returned an exit code equal to or greater than number. - command -- Specifies the command that should be carried out if the preceding condition is met. - string1==string2 -- Specifies a true condition only if string1 and string2 are the same. These values can be literal strings or batch variables (for example, %1). Quotation marks around literal strings are not needed. - EXIST FileName -- Specifies a true condition if FileName exists. - CompareOp -- Specifies a three-letter comparison operator. The following table lists valid values for CompareOp. Operator - Description EQU - equal to NEQ - not equal to LSS - less than LEQ - less than or equal to GTR - greater than GEQ - greater than or equal to - /i -- Forces string comparisons to ignore case. Use /i on the string1==string2 form of if. These comparisons are generic, in that if both string1 and string2 are both comprised of all numeric digits, the strings are converted to numbers and a numeric comparison is performed. - cmdextversion number -- Specifies a true condition only if the internal version number associated with the Command Extensions feature of Cmd.exe is equal to or greater than number. The first version is 1. It is incremented by one when significant enhancements are added to the command extensions. The cmdextversion conditional is never true when command extensions are disabled (by default, command extensions are enabled). - defined variable -- Specifies a true condition if variable is defined. - expression -- Specifies a command-line command and any parameters to be passed to the command in an else clause. - /? -- Displays help at the command prompt. Remarks: If the condition specified in an if command is true, the command that follows the condition is carried out. If the condition is false, the command in the if clause is ignored, and executes any command in the else clause, if one has been specified. When a program stops, it returns an exit code. Use exit codes as conditions by using the errorlevel parameter. Using defined variable: ======================= If a defined variable is used, the following three variables are added: %errorlevel%, %cmdcmdline%, and %cmdextversion%. %errorlevel% expands into a string representation of the current value of errorlevel, provided that there is not already an environment variable with the name ERRORLEVEL, in which case the ERRORLEVEL value is gotten instead. The following example illustrates how to use errorlevel after running a batch program: goto answer%errorlevel% :answer0 echo Program had return code 0 :answer1 echo Program had return code 1 goto end :end echo done! The CompareOp comparison operators cn be used as follows: if %errorlevel% LEQ 1 goto okay %cmdcmdline% expands into the original command line passed to Cmd.exe prior to any processing by Cmd.exe, provided that there is not already an environment variable with the name cmdcmdline, in which case the cmdcmdline value is goten instead. %cmdextversion% expands into the a string representation of the current value of cmdextversion, provided that there is not already an environment variable with the name CMDEXTVERSION, in which case the CMDEXTVERSION value is gotten instead. Using the else clause: ====================== The else clause must be used on the same line as the command after the if. For example: IF EXIST filename. ( del filename. ) ELSE ( echo filename. missing. ) The following code does not work because the del command must be terminated by a new line: IF EXIST filename. del filename. ELSE echo filename. missing The following code does not work because the else clause must be used on the same line as the end of the if command: IF EXIST filename. del filename. ELSE echo filename. missing To format it all on a single line, use the following form of the original statement: IF EXIST filename. (del filename.) ELSE echo filename. missing Examples: If the file Product.dat cannot be found, the following message appears: if not exist product.dat echo Can't find data file If an error occurs during the formatting of the disk in drive A, the following example displays an error message: :begin @echo off format a: /s if not errorlevel 1 goto end echo An error occurred during formatting. :end echo End of batch program. If no error occurs, the error message does not appear. The if command cannot be ysed to test directly for a directory, but the null (NUL) device does exist in every directory. As a result, it is possible to test for the null device to determine whether a directory exists. The following example tests for the existence of a directory: if exist c:\mydir\nul goto process
Internet Explorer Options This is a short cut to start up the INTERNET OPTIONS portion of the Control Panel. Either make a shortcut on the desktop with this or do START then RUN then type in INETCPL.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
Internet Explorer
These are the short cut keys available in Internet Explorer.
- ALT + ARROW LEFT
- Go back to the previous page (if there is one in the History list)
- ALT + ARROW RIGHT
- Go forward to the next page (if there is one in the History list)
- ALT + HOME
- Go to the Home page (as selected in the Internet Options, not the home page of the current web site)
- BACKSPACE
- Go back to the previous page (if there is one in the History list)
- CTRL + A
- Select all text/graphics on the current page
- CTRL + C
- Copy selected items to the Windows clipboard
- CTRL + D
- Open the Add to Favorites dialog for the current web page
- CTRL + E
- Open the Search bar
- CTRL + ENTER
- Adds the http://www. (url) .com
- CTRL + F
- Start a Find/Search for text on the current page
- CTRL + H
- Open the History bar
- CTRL + I
- Open the Favorites bar
- CTRL + N
- Open a new window
- CTRL + O
- Open the Open a new Webpage dialog to go to another URL
- CTRL + P
- Print the current web page or active frame
- CTRL + S
- Save the current web page
- CTRL + TAB
- Move forward between frames
- CTRL + V
- Insert contents of the Windows clipboard
- CTRL + W
- Close the browser window in focus
- END
- Move to the end of a document
- ENTER
- Activate a selected link
- ESC
- Stop downloading a web page
- F1
- Display Internet Explorer Help
- F4
- Display list of typed addresses
- F5
- Refresh the current page
- F6
- Toggle focus between the Address bar (and highlight the entire URL text) and the web page
- F11
- Toggle full-screen view
- HOME
- Move to the beginning of a document
- SHIFT + CLICK
- Open link in new window
- SHIFT + CTRL + TAB
- Move back between frames
- SHIFT + F10
- Open the context menu for the current web page (then use the up/down arrows to navigate the menu)
- SHIFT + TAB
- Move back through the items on a web page
- TAB
- Move forward through items on a web page
Regional Settings This is a short cut to start up the REGIONAL Settings portion of the Control Panel. Either make a shortcut on the desktop with this or do START then RUN then type in INTL.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
IPCONFIG Displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol (DHCP) and Domain Name System (DNS) settings. Used without parameters, ipconfig displays the IP address, subnet mask, and default gateway for all adapters. ipconfig [/all] [/renew [Adapter]] [/release [Adapter]] [/flushdns] [/displaydns] [/registerdns] [/showclassid Adapter] [/setclassid Adapter [ClassID]] Parameters: - /all -- Displays the full TCP/IP configuration for all adapters. Without this parameter, ipconfig displays only the IP address, subnet mask, and default gateway values for each adapter. Adapters can represent physical interfaces, such as installed network adapters, or logical interfaces, such as dial-up connections. - /renew [Adapter] -- Renews DHCP configuration for all adapters (if an adapter is not specified) or for a specific adapter if the Adapter parameter is included. This parameter is available only on computers with adapters that are configured to obtain an IP address automatically. To specify an adapter name, type the adapter name that appears when using ipconfig without parameters. - /release [Adapter] -- Sends a DHCPRELEASE message to the DHCP server to release the current DHCP configuration and discard the IP address configuration for either all adapters (if an adapter is not specified) or for a specific adapter if the Adapter parameter is included. This parameter disables TCP/IP for adapters configured to obtain an IP address automatically. To specify an adapter name, type the adapter name that appears when using ipconfig without parameters. - /flushdns -- Flushes and resets the contents of the DNS client resolver cache. During DNS troubleshooting, this procedure can be used to discard negative cache entries from the cache, as well as any other entries that have been added dynamically. - /displaydns -- Displays the contents of the DNS client resolver cache, which includes both entries preloaded from the local Hosts file and any recently obtained resource records for name queries resolved by the computer. The DNS Client service uses this information to resolve frequently queried names quickly, before querying its configured DNS servers. - /registerdns -- Initiates manual dynamic registration for the DNS names and IP addresses that are configured at a computer. This parameter can be used to troubleshoot a failed DNS name registration or resolve a dynamic update problem between a client and the DNS server without rebooting the client computer. The DNS settings in the advanced properties of the TCP/IP protocol determine which names are registered in DNS. - /showclassid Adapter -- Displays the DHCP class ID for a specified adapter. To see the DHCP class ID for all adapters, use the asterisk (*) wildcard character in place of Adapter. This parameter is available only on computers with adapters that are configured to obtain an IP address automatically. - /setclassid Adapter [ClassID] -- Configures the DHCP class ID for a specified adapter. To set the DHCP class ID for all adapters, use the asterisk (*) wildcard character in place of Adapter. This parameter is available only on computers with adapters that are configured to obtain an IP address automatically. If a DHCP class ID is not specified, the current class ID is removed. - /? -- Displays help at the command prompt. Remarks: The ipconfig command is the command-line equivalent to the winipcfg command, which is available in Windows Millennium Edition, Windows 98, and Windows 95. Although Windows XP does not include a graphical equivalent to the winipcfg command, Network Connections can be used to view and renew an IP address. To do this, open Network Connections, right-click a network connection, click Status, and then click the Support tab. This command is most useful on computers that are configured to obtain an IP address automatically. This enables users to determine which TCP/IP configuration values have been configured by DHCP, Automatic Private IP Addressing (APIPA), or an alternate configuration. If the Adapter name contains any spaces, use quotation marks around the adapter name (i.e., "Adapter Name"). For adapter names, ipconfig supports the use of the asterisk (*) wildcard character to specify either adapters with names that begin with a specified string or adapters with names that contain a specified string. For example, Local* matches all adapters that start with the string Local and *Con* matches all adapters that contain the string Con. This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections Examples: To display the basic TCP/IP configuration for all adapters, type: ipconfig To display the full TCP/IP configuration for all adapters, type: ipconfig /all To renew a DHCP-assigned IP address configuration for only the Local Area Connection adapter, type: ipconfig /renew "Local Area Connection" To flush the DNS resolver cache when troubleshooting DNS name resolution problems, type: ipconfig /flushdns To display the DHCP class ID for all adapters with names that start with Local, type: ipconfig /showclassid Local* To set the DHCP class ID for the Local Area Connection adapter to TEST, type: ipconfig /setclassid "Local Area Connection" TEST
Joystick Settings This is a short cut to start up the JOYSTICK Settings portion of the Control Panel. Either make a shortcut on the desktop with this or do START then RUN then type in JOY.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
Keyboard Settings This is a short cut to start up the KEYBOARD Settings portion of the Control Panel. Either make a shortcut on the desktop with this or do START then RUN then type in 'MAIN.CPL KEYBOARD' and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
LABEL Creates, changes, or deletes the volume label (i.e., the name) of a disk. label [Drive:][label] label [/MP][volume][label] Parameters: - Drive: -- Specifies the drive letter (followed by a colon) of the disk to name. - label -- Specifies the name for the volume. - /MP -- Specifies that the volume should be treated as a mount point or volume name. - volume -- Specifies the drive letter (followed by a colon), mount point, or volume name. If a volume name is specified, the /MP parameter is unnecessary. - /? -- Displays help at the command prompt. Remarks: Used without parameters, label changes the current volume label or deletes the existing label. Windows displays the volume label as part of the directory listing. If a volume serial number exists, Windows displays this number as well. Label command messages ======================= If a label is not specified, label displays a message in the following format: Volume in drive A is xxxxxxxxxxx Volume Serial Number is xxxx-xxxx Volume label (11 characters, ENTER for none)? The "Volume Serial Number" part of the message is not displayed if the disk has no serial number. The volume label can be typed or just press ENTER to delete the current label. If a disk has a label and ENTER is pressed for none, label prompts with the following message: Delete current volume label (Y/N)? Press Y to delete the label; press N to keep the label. Limitations on volume label names ================================== A volume label can contain as many as 32 characters for NTFS volumes and as many as 11 characters for FAT volumes and can include spaces but no tabs. FAT volume labels cannot contain any of the following characters: * ? / \ | . , ; -- + = [ ] < > " This limitation does not apply to NTFS volumes. For FAT volumes, volume labels are stored as uppercase regardless of whether they contain lowercase letters. NTFS volume labels retain and display the case used when the label was created. Examples: To label a disk in drive A that contains sales information for July, type: label a:sales-july
Mouse Settings This is a short cut to start up the MOUSE Settings portion of the Control Panel. Either make a shortcut on the desktop with this or do START then RUN then type in MAIN.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
MD Creates a directory. mkdir [Drive:]Path md [Drive:]Path Parameters: - Drive: -- Specifies the drive on which to create the new directory. - Path -- Required. Specifies the name and location of the new directory. The maximum length of any single path is determined by the file system. - /? -- Displays help at the command prompt. Remarks: When command extensions are enabled (i.e. the default), a single md command can be used to create intermediate directories in a specified path. For more information about enabling and disabling command extensions, see cmd in Related Topics. Examples: To create a directory named Taxes with a subdirectory named Property, which contains a subdirectory named Current, type: md \Taxes\Property\Current This is the same as typing the following sequence of commands with command extensions disabled: md \Taxes cd \Taxes md Property cd Property md Current
MKDIR Creates a directory. See MD
MODE Displays system status, changes system settings, or reconfigures ports or devices. To configure a serial communications port mode comm[:] [baud=b] [parity=p] [data=d] [stop=s] [to={on|off}] [xon={on|off}] [odsr={on|off}] [octs={on|off}] [dtr={on|off|hs}] [rts={on|off|hs|tg}] [idsr={on|off}] Parameters: - comm[:] -- Specifies the number of the asynchronous-communications (COM) port. - baud=b -- Specifies the transmission rate in bits per second. The following table lists valid abbreviations for b and its related rate. Value - Rate 11 - 110 baud 15 - 150 baud 30 - 300 baud 60 - 600 baud 12 - 1200 baud 24 - 2400 baud 48 - 4800 baud 96 - 9600 baud 19 - 19,200 baud - parity=p -- Specifies how the system uses the parity bit to check for transmission errors. The following table lists valid p values. The default value is e. Not all computers support the values m and s. Value - Description n - none e - even o - odd m - mark s - space - data=d -- Specifies the number of data bits in a character. Valid values for d are in the range 5 through 8. The default value is 7. Not all computers support the values 5 and 6. - stop=s -- Specifies the number of stop bits that define the end of a character: 1, 1.5, or 2. If the baud rate is 110, the default value is 2. Otherwise, the default value is 1. Not all computers support the value 1.5. - to={on|off} -- Specifies whether infinite time-out processing is on or off. The default is off. - xon={on|off} -- Specifies whether the xon or xoff protocol for data-flow control is on or off. - odsr={on|off} -- Specifies whether output handshaking that uses the Data Set Ready (DSR) circuit is on or off. - octs={on|off} -- Specifies whether output handshaking that uses the Clear To Send (CTS) circuit is on or off. - dtr={on|off|hs} -- Specifies whether the Data Terminal Ready (DTR) circuit is on or off, or set to handshake. - rts={on|off|hs|tg} -- Specifies whether the Request To Send (RTS) circuit is set to on, off, handshake, or toggle. - idsr={on|off} -- Specifies whether the DSR circuit sensitivity is on or off. - /? -- Displays help at the command prompt. To display the status of all devices or of a single device Syntax: mode [device] [/status] Parameters: - device -- Specifies the name of the device to display the status. - /status -- Requests the status of any redirected parallel printers. The /status command-line option can be abbreviated as /sta. - /? -- Displays help at the command prompt. Remarks: Used without parameters, mode displays all the controllable attributes of the console and the available COM devices. Because mode can be used to perform many different tasks, the syntax needs to be used to carry out each task is different. Click the task that to perform. To redirect output from a parallel port to a serial communications port Syntax: mode lptn[:]=comm[:] Parameters: - lptn -- Required. Specifies the parallel port. Valid values for n are in the range 1 through 3. - comm [:] -- Required. Specifies the serial port. Valid values for m are in the range 1 through 4. - /? -- Displays help at the command prompt. Remarks: Redirect printing can only be done by a member of the Administrators group. Examples: To set up te system so that it sends parallel-printer output to a serial printer, the mode command must be used twice. The first time, use mode to configure the serial port. The second time, use mode to redirect parallel-printer output to the serial port specified in the first mode command. For example, if the serial printer operates at 4800 baud with even parity and is connected to the COM1 port (the first serial connection on the computer), type: mode com1 48,e,,,b mode lpt1=com1 If parallel-printer output is redirected from LPT1 to COM1 but then decide to print a file by using LPT1, type the following command before printing the file: mode lpt1 This command prevents the redirection the file from LPT1 to COM1. To select, refresh, or display the numbers of the code pages for the console Syntax: mode device codepage select=yyy mode device codepage [/status] Parameters: - device -- Required. Specifies the device to select a code page. CON is the only valid name for a device. - codepage select= -- Required. Specifies which code page to use with the specified device. codepage can be abbreviated and select as cp and sel, respectively. - yyy -- Required. Specifies the number of the code page to select. The following table lists each code page supported and its Country/Region or language. Value - Country/Region 437 - United States 850 - Multilingual (Latin I) 852 - Slavic (Latin II) 855 - Cyrillic (Russian) 857 - Turkish 860 - Portuguese 861 - Icelandic 863 - Canadian-French 865 - Nordic 866 - Russian 869 - Modern Greek - codepage -- Required. Displays the numbers of the code pages, if any, that are selected for the specified device. - /status -- Displays the numbers of the current code pages selected for the specified device. /status can be abbreviated to /sta. Whether or not /status is specified, mode codepage displays the numbers of the code pages that are selected for the specified device. - /? -- Displays help at the command prompt. To change the size of the command prompt screen buffer Syntax: mode con[:] [cols=c] [lines=n] Parameters: - con[:] -- Required. Indicates that the change is to the command prompt window. - cols=c -- Specifies the number of characters (columns) wide in the command prompt screen buffer. - lines=n -- Specifies the number of lines deep in the command prompt screen buffer. - /? -- Displays help at the command prompt. To set the keyboard typematic rate Syntax: mode con[:] [rate=r delay=d] Parameters: - con[:] -- Required. Refers to the keyboard. - rate=r -- Specifies the rate at which a character is repeated on the screen when a key is held down. - delay=d -- Specifies the amount of time that must elapse, after pressing and hold down a key, before the character output starts to repeat. - /? -- Displays help at the command prompt. Remarks: The typematic rate is the rate at which a character repeats when the key is held down for that character. The typematic rate has two components, the rate and the delay. Some keyboards do not recognize this command. Using rate=r Valid values are in the range 1 through 32. These values are equal to approximately 2 to 30 characters per second, respectively. The default value is 20 for IBM AT-compatible keyboards, and 21 for IBM PS/2-compatible keyboards. If the rate is set, the delay must also be set. Using delay=d Valid values for d are 1, 2, 3, and 4 (representing 0.25, 0.50, 0.75, and 1 second, respectively). The default value is 2. If the rate is set, the delay must also be set.
Modem Settings This is a short cut to start up the MODDEM Settings portion of the Control Panel. Either make a shortcut on the desktop with this or do START then RUN then type in 'CONTROL MODEM' and click OK. Of course, it can also be entered at the C:\ prompt in a CMD window.
MORE Displays output one screen at a time. command | more [/c] [/p] [/s] [/tn] [+n] more [[/c] [/p] [/s] [/tn] [+n]] < [Drive:] [Path] FileName more [/c] [/p] [/s] [/tn] [+n] [files] Parameters: - [Drive:] [Path] FileName -- Specifies the file to display. - command -- Specifies a command to display the output. - /c -- Clears screen before displaying page. - /p -- Expands form-feed characters. - /s -- Changes multiple blank lines to one blank line. - /tn -- Changes tabs to the number of spaces specified by n. - +n -- Displays first file beginning at the line specified by n. - files -- Specifies list of files to display. Separate file names with a space. - /? -- Displays help at the command prompt. Remarks: Using more at the Recovery Console: =================================== The more command, with different parameters, is available from the Recovery Console. Using more subcommands: ======================= The following commands are accepted at the more prompt (-- More --). Key - Action SPACEBAR - Display next page ENTER - Display next line f - Display next file q - Quit ? - Show available commands = - Show line number p n - Display next n lines s n - Skip next n lines Sources of data: ================ When using the redirection character (<), a file name must be specified as the source. When using the pipe (|), such commands as dir, sort, and type can be used. Examples: To view the file named Clients.new on the screen, type either of the following two commands: more < clients.new type clients.new | more The more command displays the first screen of information from Clients.new, and then the following prompt appears: -- More -- Press the SPACEBAR to see the next screen of information. To clear the screen and remove all extra blank lines before displaying the file Clients.new, type either of the following two commands: more /c /s < clients.new type clients.new | more /c /s The more command displays the first screen of information from Clients.new, and then the following prompt appears: -- More -- To display the file one line at a time, press ENTER. To display the next page, press the SPACEBAR. To display the next file listed on the command line, type f. To quit more, type q. Add commands to the more prompt as shown in this example: -- More [Options: psfq=] -- To display the current line number, type =. The current line number is added to the more prompt as shown in this example: -- More [Line: 24] -- To display a specific number of lines, type p. More prompts for the number of lines to display as follows: -- More -- Lines: Type the number of lines to display and press ENTER. More displays the specified number of lines. To skip a specific number of lines, type s. More prompts for the number of lines to skip as follows: -- More -- Lines: Type the number of lines to skip, and then press ENTER. More skips the specified number of lines and displays the next screen of information.
MOVE Moves one or more files from one directory to the specified directory. move [{/y|/-y}] [Source] [target] Parameters: - /y -- Suppresses prompting to confirm to overwrite an existing destination file. - /-y -- Causes prompting to confirm to overwrite an existing destination file. - Source -- Specifies the path and name of the file or files to move. If moving or renaming a directory, Source should be the current directory path and name. - target -- Specifies the path and name to move files to. To move or rename a directory, the target should be the desired directory path and name. - /? -- Displays help at the command prompt. Remarks: Using the /y command-line option: ================================= The /y command-line option might be preset in the COPYCMD environment variable. This can be overridden this with /-y on the command line. The default is to prompt on overwrites unless the copy command is being executed from within a batch script. Moving encrypted files: ======================= Moving encrypted files to a volume that does not support Encrypting File System (EFS) results in an error. Decrypt the files first or move the files to a volume that does support EFS. Examples: To move all files with the .xls extension from the \Data directory to the \Second_Q\Reports directory, type the following: move \data\*.xls \second_q\reports\
MSG Send a message to a user MSG {username | sessionname | sessionid | @filename | *} [/SERVER:servername] [/TIME:seconds] [/V] [/W] [message] Parameters: - username Identifies the specified username. - sessionname The name of the session. - sessionid The ID of the session. - @filename Identifies a file containing a list of usernames, sessionnames, and sessionids to send the message to. - * Send message to all sessions on specified server. - /SERVER:servername server to contact (default is current). - /TIME:seconds Time delay to wait for receiver to acknowledge msg. - /V Display information about actions being performed. - /W Wait for response from user, useful with /V. - message Message to send. If none specified, prompts for it or reads from stdin. Examples: - To send the message entitled Let's meet at 1PM today to all sessions for user MIKES, type: msg MIKES Let's meet at 1PM today - To send the same message to session MODEM02, type: msg modem02 Let's meet at 1PM today - To send the message to session 12, type: msg 12 Let's meet at 1PM today - To send the message to all sessions contained in the file USERLIST, type: msg @userlist Let's meet at 1PM today - To send the message to all users who are logged on, type: msg * Let's meet at 1PM today - To send the message to all users, with an acknowledgment time-out (for example, 10 seconds), type: msg * /TIME:10 Let's meet at 1PM today
MSCONFIG System configuration This includes such things as programs run at STARTUP and Services which can be unchecked to remove them from this active list. MSCONFIG
MSTSC Connect to a remote PC mstsc [/v:server[:port]] [/w:pixels] [h:pixels] [/prompt] [/admin] [/?] Parameters: /v:server:port -- specify the server, and optionally the port, which to connect to /admin -- connect to the session as an administrator /prompt -- go through the credentials logon before allowing the connection /f -- make the connection window be in full screen mode /W:pixels -- specify how many pixels wide to make the connection window /h:pixels -- specify how many pixels high to make the connection window /span -- make the connection window span across multiple monitors /? -- Displays help at the command prompt. Remarks: MSTSC allows connection to a remote PC/server as if sitting in front of that PC/server NOTE: there are several other options for this command such as /public and /multimon and /shadow and /control and/noConsentPrompt and "connection file" but would probably rarely be used thus are not documented here. To see more, type in: mstsc /? Examples: To start up the GUI to connect to a remote PC, type: mstsc To connect to the PC by name and require a logon, type: mstsc /v:\\ABC00123456W7 /prompt
NBTSTAT Displays NetBIOS over TCP/IP (NetBT) protocol statistics, NetBIOS name tables for both the local computer and remote computers, and the NetBIOS name cache. nbtstat [-a RemoteName] [-A IPAddress] [-c] [-n] [-r] [-R] [-RR] [-s] [-S] [Interval] Parameters: -a RemoteName -- Displays the NetBIOS name table of a remote computer, where RemoteName is the NetBIOS computer name of the remote computer. The NetBIOS name table is the list of NetBIOS names that corresponds to NetBIOS applications running on that computer. -A IPAddress -- Displays the NetBIOS name table of a remote computer, specified by the IP address (in dotted decimal notation) of the remote computer. -c -- Displays the contents of the NetBIOS name cache, the table of NetBIOS names and their resolved IP addresses. -n -- Displays the NetBIOS name table of the local computer. The status of Registered indicates that the name is registered either by broadcast or with a WINS server. -r -- Displays NetBIOS name resolution statistics. On a Windows XP computer that is configured to use WINS, this parameter returns the number of names that have been resolved and registered using broadcast and WINS. -R -- Purges the contents of the NetBIOS name cache and then reloads the #PRE-tagged entries from the Lmhosts file. -RR -- Releases and then refreshes NetBIOS names for the local computer that is registered with WINS servers. -s -- Displays NetBIOS client and server sessions, attempting to convert the destination IP address to a name. -S -- Displays NetBIOS client and server sessions, listing the remote computers by destination IP address only. Interval -- Redisplays selected statistics, pausing the number of seconds specified in Interval between each display. Press CTRL+C to stop redisplaying statistics. If this parameter is omitted, nbtstat prints the current configuration information only once. /? -- Displays help at the command prompt. Remarks: Nbtstat allows a refresh of the NetBIOS name cache and the names registered with Windows Internet Name Service (WINS). Used without parameters, nbtstat displays help. Nbtstat command-line parameters are case-sensitive. The following table describes the column headings that are generated by nbtstat. Heading - Description Input - The number of bytes received. Output - The number of bytes sent. In/Out - Whether the connection is from the computer (outbound) or from another computer to the local computer (inbound). Life - The remaining time that a name table cache entry will live before it is purged. Local Name - The local NetBIOS name associated with the connection. Remote Host - The name or IP address associated with the remote computer. <03> - The last byte of a NetBIOS name converted to hexadecimal. Each NetBIOS name is 16 characters long. This last byte often has special significance because the same name might be present several times on a computer, differing only in the last byte. For example, <20> is a space in ASCII text. Type - The type of name. A name can either be a unique name or a group name. Status - Whether the NetBIOS service on the remote computer is running (Registered) or a duplicate computer name has registered the same service (Conflict). State - The state of NetBIOS connections. The following table describes the possible NetBIOS connection states. State - Description Connected - A session has been established. Associated - A connection endpoint has been created and associated with an IP address. Listening - This endpoint is available for an inbound connection. Idle - This endpoint has been opened but cannot receive connections. Connecting - A session is in the connecting phase and the name-to-IP address mapping of the destination is being resolved. Accepting - An inbound session is currently being accepted and will be connected shortly. Reconnecting - A session is trying to reconnect (it failed to connect on the first attempt). Outbound - A session is in the connecting phase and the TCP connection is currently being created. Inbound - An inbound session is in the connecting phase. Disconnecting - A session is in the process of disconnecting. Disconnected - The local computer has issued a disconnect and it is waiting for confirmation from the remote system. This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections Examples: To display the NetBIOS name table of the remote computer with the NetBIOS computer name of CORP07, type: nbtstat -a CORP07 To display the NetBIOS name table of the remote computer assigned the IP address of 10.0.0.99, type: nbtstat -A 10.0.0.99 To display the NetBIOS name table of the local computer, type: nbtstat -n To display the contents of the local computer NetBIOS name cache, type: nbtstat -c To purge the NetBIOS name cache and reload the #PRE-tagged entries in the local Lmhosts file, type: nbtstat -R To release the NetBIOS names registered with the WINS server and re-register them, type: nbtstat -RR To display NetBIOS session statistics by IP address every five seconds, type: nbtstat -S 5
NET Network Services NET [service] Parameters: - [service] -- Name of the network service - /? -- Displays help at the command prompt. - [service] /? -- Displays help at the command prompt for a specified service. Remarks: The services available are: - Net accounts -- Updates the user accounts database and modifies password and logon requirements for all accounts. - Net computer -- Adds or deletes computers from a domain database. - Net config -- Displays the configurable services that are running, or displays and changes settings for a Server service or a Workstation service. Used without parameters, net config displays a list of configurable services. - Net continue -- Continues a service that has been suspended by net pause. - Net file -- Displays/closes the names of all open shared files on a server and the number of file locks, if any, on each file. - Net group -- Adds, displays, or modifies global groups in domains. - Net help x -- Provides a list of network commands and topics for which you can get help, or provides information about a specific command. - Net helpmsg -- Explains why an error occurred and provides problem-solving information. - Net localgroup -- Adds, displays, or modifies local groups. Used without parameters, net localgroup displays the name of the server and the names of local groups on the computer. - Net name -- Adds or deletes a messaging name (that is, an alias), or displays the list of names for which the computer can accept messages. - Net pause -- Pauses services that are currently running. - Net print -- Displays information about a specified print queue, displays information about all print queues hosted by a specified print server, displays information about a specified print job, or controls a specified print job. - Net send -- Sends messages to other users, computers, or messaging names on the network. - Net session -- Manages server computer connections. Used without parameters, net session displays information about all sessions with the local computer. - Net share -- Manages shared resources. Used without parameters, net share displays information about all of the resources that are shared on the local computer. - Net start -- Starts a service. Used without parameters, net start displays a list of services that are currently operating. - Net statistics -- Displays the statistics log for the local Workstation or Server service, or the running services for which statistics are available. - Net stop -- Stops a running service. - Net time -- Synchronizes the computer's clock with that of another computer or domain. - Net use -- Connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections. The command also controls persistent net connections. - Net user -- Adds or modifies user accounts or displays user account information. - Net view -- Displays a list of domains, computers, or resources that are being shared by the specified computer.
NETSTAT Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). netstat [-a] [-e] [-n] [-o] [-p Protocol] [-r] [-s] [Interval] Parameters: - -a -- Displays all active TCP connections and the TCP and UDP ports on which the computer is listening. - -e -- Displays Ethernet statistics, such as the number of bytes and packets sent and received. This parameter can be combined with -s. - -n -- Displays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names. - -o -- Displays active TCP connections and includes the process ID (PID) for each connection. The application based on the PID can be found on the Processes tab in Windows Task Manager. This parameter can be combined with -a, -n, and -p. - -p Protocol -- Shows connections for the protocol specified by Protocol. In this case, the Protocol can be tcp, udp, tcpv6, or udpv6. If this parameter is used with -s to display statistics by protocol, Protocol can be tcp, udp, icmp, ip, tcpv6, udpv6, icmpv6, or ipv6. - -s -- Displays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. If the IPv6 protocol for Windows XP is installed, statistics are shown for the TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols. The -p parameter can be used to specify a set of protocols. - -r -- Displays the contents of the IP routing table. This is equivalent to the route print command. - Interval -- Redisplays the selected information every Interval seconds. Press CTRL+C to stop the redisplay. If this parameter is omitted, netstat prints the selected information only once. - /? -- Displays help at the command prompt. Remarks: Used without parameters, netstat displays active TCP connections. Parameters used with this command must be prefixed with a hyphen (-) rather than a slash (/). Netstat provides statistics for the following: Proto - The name of the protocol (TCP or UDP). Local Address - The IP address of the local computer and the port number being used. The name of the local computer that corresponds to the IP address and the name of the port is shown unless the -n parameter is specified. If the port is not yet established, the port number is shown as an asterisk (*). Foreign Address - The IP address and port number of the remote computer to which the socket is connected. The names that corresponds to the IP address and the port are shown unless the -n parameter is specified. If the port is not yet established, the port number is shown as an asterisk (*). (state) - Indicates the state of a TCP connection. The possible states are as follows: -- CLOSE_WAIT -- CLOSED -- ESTABLISHED -- FIN_WAIT_1 -- FIN_WAIT_2 -- LAST_ACK -- LISTEN -- SYN_RECEIVED -- SYN_SEND -- TIMED_WAIT For more information about the states of a TCP connection, see RFC 793. This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections Examples: To display both the Ethernet statistics and the statistics for all protocols, type the following command: netstat -e -s To display the statistics for only the TCP and UDP protocols, type the following command: netstat -s -p tcp udp To display active TCP connections and the process IDs every 5 seconds, type the following command: netstat -o 5 To display active TCP connections and the process IDs using numerical form, type the following command: netstat -n -o
Notepad Text Editor
This is a short cut to start up the Notepad text editor. This simple editor is
useful for viewing and modifying files whose contents is made up only of the
ASCII characters found on a typical keyboard. No formatting (e.g. bold, font
size, tables, etc.) can be done within Notepad.
When NOTEPAD is started, an optional file name can be given.
Either make a shortcut on the desktop with this or do START then RUN then type in
NOTEPAD and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Removable Storage Manager
This is a short cut to start up the Removable Storage Manager dialog.
Either make a shortcut on the desktop with this or do START then RUN then type in
NTMSMGMT.MSC and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
ODBCAD32
This is a short cut to start up the ODBC Data Source Administrator dialog
portion of the Control Panel. ODBC is where databases are configured so that
they are accessible in applications.
Either make a shortcut on the desktop with this or do START then RUN then type in
ODBCAD32 and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
MS-Paint Graphics Editor
This is a short cut to start up the MS-Paint graphics editor. This simple editor is
useful for viewing and modifying files whose contents are basically a graphic image.
When MSPAINT is started, an optional file name can be given.
Either make a shortcut on the desktop with this or do START then RUN then type in
MSPAINT and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
PATH Sets the command path in the PATH environment variable, which is the set of directories used to search for executable files. path [[%path%] [Drive:]Path [;...]] Parameters: - [Drive:]Path -- Specifies the drive and directory to set in the command path. - ; -- Separates directories in the command path. - %path% -- Specifies Windows XP to append the command path to the existing set of directories listed in the PATH environment variable. - /? -- Displays help at the command prompt. Remarks: Used without parameters, path displays the current command path. Using ;: ======== When used as the only parameter, ; deletes the existing command path value found in the PATH variable. Using %path%: ============= When %path% is included in the syntax, Cmd.exe replaces it with the command path value found in the PATH variable, eliminating the need to manually enter these values at the command line. For more information about substituting environment variable values, see Command shell overview in Related Topics. Current directory The operating system always searches in the current directory first, before it searches the directories in the command path. Files with the same name, different extensions: =============================================== Some files might be in the same directory that share the same file name but have different extensions. For example, there might have a file named Accnt.com that starts an accounting program and another file named Accnt.bat that connects the system to the accounting system network. The operating system searches for a file by using default file name extensions in the following order of precedence: .exe, .com, .bat, and .cmd. To run Accnt.bat when Accnt.com exists in the same directory, the .bat extension must be given on the command line. Two or more identical file names in the path" ============================================= If there are two or more files in the command path that have the same file name and extension, Windows XP searches for the specified file name first in the current directory, and then it searches the directories in the command path in the order in which they are listed in PATH. Searching the MS-DOS subsystem: =============================== If the path command is placed in the Autoexec.nt file, it automatically appends the specified MS-DOS subsystem search path to the Windows XP search path at every log on to the computer. Cmd.exe does not use the Autoexec.nt file. When started from a shortcut, Cmd.exe inherits the environment variables set in My Computer/Properties/Advanced/Environment. Examples: The following command specifies that Windows XP is to search three directories to find external commands. The three paths for these directories are C:\User\Taxes, B:\User\Invest, and B:\Bin: path c:\user\taxes;b:\user\invest;b:\bin
PAUSE Suspends processing of a batch program and displays a message prompting the user to press any key to continue. pause Parameters: /? -- Displays help at the command prompt. Remarks: When run the prompt command, the following message appears: Press any key to continue . . . If CTRL+C is pressed to stop a batch program, the following message appears: Terminate batch job (Y/N)? If press Y (for yes) in response to this message, the batch program ends and control returns to the operating system. Therefore, the pause command can be inserted before a section of the batch file that may not want to be processed. While pause suspends processing of the batch program, pressing CTRL+C and then Y to stop the batch program. Examples: To create a batch program that prompts the user to change disks in one of the drives, type: @echo off :begin copy a:*.* echo Please put a new disk into drive A pause goto begin In this example, all the files on the disk in drive A are copied to the current directory. After the displayed comment prompts to place another disk in drive A, the pause command suspends processing so that disks can be changed and then press any key to resume processing. This particular batch program runs in an endless loop. The goto BEGIN command sends the command interpreter to the begin label of the batch file. To stop this batch program, press CTRL+C and then Y.
PERFMON Open a Windows XP Performance console configured with settings files from Windows NT 4.0 version of Performance Monitor. perfmon.exe [file_name] [/HTMLFILE:converted_file settings_file] Parameters: - .exe -- Specifies the name of the file extension. - file_name -- Specifies the name of the settings file. - /HTMLFILE:converted_file settings_file -- Specifies the name of the converted files, and the name of the original Windows NT 4.0 settings file. Remarks: This procedure works for the following types of Windows NT 4.0 version of Performance Monitor settings files: chart (.pmc), report (.pmr), alert (.pma), and log (.pml). To display the Windows NT 4.0 settings file in System Monitor, the system temporarily converts the file for use with Windows XP System Monitor, then discards the converted version after the console starts. To save the settings file for permanent use with System Monitor, type: Perfmon [file_name] [/HTMLFILE:converted_file settings_file] Where /HTMLFILE:converted_file is the name given to the converted file and settings_file is the name of the original Windows NT 4.0 settings file. For more information about incorporating Perfmon into the Windows Management Instrumentation (WMI) scripts, see Scripting Logs and Monitoring at the Microsoft Windows Resource Kits Web site. Examples: To list the settings file, type: Perfmon myfile_overview To list converted and original file names, type: Perfmon myfile_overview /Commands:newfile_review oldfile_sample.pml
PING Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol (ICMP) Echo Request messages. ping [-t] [-a] [-n Count] [-l Size] [-f] [-i TTL] [-v TOS] [-r Count] [-s Count] [{-j HostList | -k HostList}] [-w Timeout] [TargetName] Parameters: - -t -- Specifies that ping continue sending Echo Request messages to the destination until interrupted. To interrupt and display statistics, press CTRL-BREAK. To interrupt and quit ping, press CTRL-C. - -a -- Specifies that reverse name resolution is performed on the destination IP address. If this is successful, ping displays the corresponding host name. - -n Count -- Specifies the number of Echo Request messages sent. The default is 4. - -l Size -- Specifies the length, in bytes, of the Data field in the Echo Request messages sent. The default is 32. The maximum size is 65,527. - -f -- Specifies that Echo Request messages are sent with the Don't Fragment flag in the IP header set to 1. The Echo Request message cannot be fragmented by routers in the path to the destination. This parameter is useful for troubleshooting path Maximum Transmission Unit (PMTU) problems. - -i TTL -- Specifies the value of the TTL field in the IP header for Echo Request messages sent. The default is the default TTL value for the host. For Windows XP hosts, this is typically 128. The maximum TTL is 255. - -v TOS -- Specifies the value of the Type of Service (TOS) field in the IP header for Echo Request messages sent. The default is 0. TOS is specified as a decimal value from 0 to 255. - -r Count -- Specifies that the Record Route option in the IP header is used to record the path taken by the Echo Request message and corresponding Echo Reply message. Each hop in the path uses an entry in the Record Route option. If possible, specify a Count that is equal to or greater than the number of hops between the source and destination. The Count must be a minimum of 1 and a maximum of 9. - -s Count -- Specifies that the Internet Timestamp option in the IP header is used to record the time of arrival for the Echo Request message and corresponding Echo Reply message for each hop. The Count must be a minimum of 1 and a maximum of 4. - -j HostList -- Specifies that the Echo Request messages use the Loose Source Route option in the IP header with the set of intermediate destinations specified in HostList. With loose source routing, successive intermediate destinations can be separated by one or multiple routers. The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses (in dotted decimal notation) separated by spaces. - -k HostList -- Specifies that the Echo Request messages use the Strict Source Route option in the IP header with the set of intermediate destinations specified in HostList. With strict source routing, the next intermediate destination must be directly reachable (it must be a neighbor on an interface of the router). The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses (in dotted decimal notation) separated by spaces. - -w Timeout -- Specifies the amount of time, in milliseconds, to wait for the Echo Reply message that corresponds to a given Echo Request message to be received. If the Echo Reply message is not received within the time-out, the "Request timed out" error message is displayed. The default time-out is 4000 (4 seconds). - TargetName -- Specifies the destination, which is identified either by IP address or host name. - /? -- Displays help at the command prompt. Remarks: The receipt of corresponding Echo Reply messages are displayed, along with round-trip times. Ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution. Used without parameters, ping displays help. ping can be used to test both the computer name and the IP address of the computer. If pinging the IP address is successful, but pinging the computer name is not, there might be a name resolution problem. In this case, ensure that the specified computer name can be resolved through the local Hosts file, by using Domain Name System (DNS) queries, or through NetBIOS name resolution techniques. This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections Examples: The following example shows ping command output: C:\>ping example.microsoft.com Pinging example.microsoft.com [192.168.239.132] with 32 bytes of data: Reply from 192.168.239.132: bytes=32 time=101ms TTL=124 Reply from 192.168.239.132: bytes=32 time=100ms TTL=124 Reply from 192.168.239.132: bytes=32 time=120ms TTL=124 Reply from 192.168.239.132: bytes=32 time=120ms TTL=124 To ping the destination 10.0.99.221 and resolve 10.0.99.221 to its host name, type: ping -a 10.0.99.221 To ping the destination 10.0.99.221 with 10 Echo Request messages, each of which has a Data field of 1000 bytes, type: ping -n 10 -l 1000 10.0.99.221 To ping the destination 10.0.99.221 and record the route for 4 hops, type: ping -r 4 10.0.99.221 To ping the destination 10.0.99.221 and specify the loose source route of 10.12.0.1-10.29.3.1-10.1.44.1, type: ping -j 10.12.0.1 10.29.3.1 10.1.44.1 10.0.99.221
POPD Changes the current directory to the directory stored by the pushd command. popd Parameters: - /? -- Displays help at the command prompt. Remarks: Every time the pushd command is used, a single directory is stored for later use. However, storing multiple directories is done by using the pushd command multiple times. The directories are stored sequentially in a virtual stack. If the pushd command is used once, the directory in which the command was specified is placed at the bottom of the stack. If the command is used again, the second directory is placed on top of the first one. The process repeats every time the pushd command is used. The popd command is used to change the current directory to the directory most recently stored by the pushd command. If the popd command is used, the directory on the top of the stack is removed from the stack as the current directory is changed to that directory. If the popd command is used again, the next directory on the stack is removed. When command extensions are enabled, the popd command removes any drive-letter assignations created by pushd. Examples: pushd and popd can be used in a batch program to change the current directory from the one in which the batch program was run and then change it back. The following sample batch program shows how to do this: @echo off rem This batch file deletes all .txt files in a specified directory pushd %1 del *.txt popd cls echo All text files
Power Settings
This is a short cut to start up the POWER Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
POWERCFG.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
PRINT Sends a text file to a printer. print [/d:Printer] [Drive:][Path] FileName [ ...] Parameters: - /d:Printer -- Specifies the printer on which to print the file. A local printer can be specified by specifying the port on the computer to which the printer is connected. Valid values for parallel ports are LPT1, LPT2, and LPT3. Valid values for serial ports are COM1, COM2, COM3, and COM4. A network printer can be specified by its queue name (\\ServerName\ShareName). If a printer is not specified, the print job is sent to LPT1. - Drive: -- Specifies the logical or physical drive on which the file to print is located. This parameter is not required if the file is located on the current drive. - Path -- Specifies where, on the drive, the file to print is located. This parameter is not required if the file to print is located in the current directory. - FileName [...] -- Required. Specifies, by name, the file to print. Multiple files can be include in one command. - /? -- Displays help at the command prompt. Remarks: A file can print in the background if it is sent to a printer connected to a serial or parallel port on the local computer. Many programs have their own print commands. The print command should be used for a program to print files created with that program. Many configuration tasks can be performed from the command line by using the mode command. For more information about configuring a printer connected to a parallel port, configuring a printer connected to a serial port, displaying the status of a printer, or preparing a printer for code page switching, see mode in Related Topics. Examples: To send the file Report.txt in the current directory to a printer connected to LPT2 on the local computer, type: print /d:LPT2 report.txt To send the file Report.txt in the c:\Accounting directory to the Printer1 print queue on the \\CopyRoom server, type: print /d:\\copyroom\printer1 c:\accounting\report.txt
Printers/Faxes Settings
This is a short cut to start up the PRINTERS/FAXES Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
'CONTROL PRINTERS' and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
PROMPT Changes the Cmd.exe prompt. prompt [text] Parameters: - text : Specifies any text and information to include in the system prompt. - /? : Displays help at the command prompt. Remarks: Used without parameters, prompt resets the command prompt to the default setting, the current drive letter followed by the current directory and a greater-than symbol (>). The command prompt can be customized to display any text desired, including such information as the name of the current directory, the time and date, and the Windows XP version number. The following table lists the character combinations that can be included instead of, or in addition to, one or more character strings in the text command-line option. The list includes a brief description of the text or information that each character combination adds to the command prompt. Character - Description $q - = (equal sign) $$ - $ (dollar sign) $t - Current time $d - Current date $p - Current drive and path $v - Windows XP version number $n - Current drive $g - > (greater-than sign) $l - < (less-than sign) $b - | (pipe) $_ - ENTER-LINEFEED $e - ANSI escape code (code 27) $h - Backspace (to delete a character that has been written to the prompt command line) $a - & (ampersand) $c - ( (left parenthesis) $f - ) (right parenthesis) $s - space When command extensions are enabled (i.e., the default) the prompt command supports the formatting characters listed in the following table. Character - Description $+ - Zero or more plus sign (+) characters depending upon the depth of the pushd directory stack, one character for each level pushed. $m - The remote name associated with the current drive letter or the empty string if current drive is not a network drive. If the $p character is included in the text parameter, the disk is read, after entering each command, to determine the current drive and path. This can take extra time, especially for floppy disk drives. Examples: The following example sets the command prompt to display the current drive and path followed by the greater-than symbol (>): prompt $p$g The following command displays a two-line prompt in which the current time appears on the first line and the current date appears on the second line: prompt time is: $t$_date is: $d
PUSHD Stores the name of the current directory for use by the popd command before changing the current directory to the specified directory. pushd [Path] Parameters: Path -- Specifies the directory to which the current directory should be changed. This command supports relative paths. - /? -- Displays help at the command prompt. Remarks: Every time the pushd command is used, a single directory is stored for later use. However, storing multiple directories is done by using the pushd command multiple times. The directories are stored sequentially in a virtual stack. If the pushd command is used once, the directory in which from which the command was specified is placed at the bottom of the stack. If the command is used again, the second directory is placed on top of the first one. The process repeats every time the pushd command is used. The popd command can be used to change the current directory to the directory most recently stored by the pushd command. If the popd command is used, the directory on the top of the stack is removed from the stack as the current directory is changed to that directory. If the popd command is used again, the next directory on the stack is removed. If command extensions are enabled, the pushd command accepts either a network path or a local drive letter and path. If a network path is specified, the pushd command temporarily assigns the first unused drive letter (starting with Z:) to the specified network resource. The command then changes the current drive and directory to the specified directory on the newly assigned drive. If the popd command is used with command extensions enabled, the popd command removes the drive-letter assignation created by pushd. Examples: The pushd command and the popd command can be used in a batch program to change the current directory from the one in which the batch program was run and then change it back. The following sample batch program shows how to do this: @echo off rem This batch file deletes all .txt files in a specified directory pushd %1 del *.txt popd cls echo All text files deleted in the %1 directory
RASDIAL Automate starting a network connection using a specific entry Automate the connection process for any Microsoft client by using a simple batch file and the rasdial command. The rasdial command starts a network connection by using a specified entry. rasdial connectionname [username [password | *]] [/domain:domain] [/phone:phonenumber] [/callback:callbacknumber] [/phonebook:phonebookpath] [/prefixsuffix] The rasdial command disconnects a network connection by using the following syntax: rasdial [connectionname] /disconnect Parameters: - None -- Used without options, rasdial displays the status of current connections. - connectionname -- Specifies an entry in the current .pbk file, located in the \systemroot\System32\Ras folder. If the connection name contains spaces or special characters, enclose the connection name in quotation marks ("). - The Rasphone.pbk file is used unless the Personal Phonebook option is selected. If the Personal Phonebook option is selected, the file username.pbk is used. The name is shown on the Rasphone title bar when Personal Phonebook/p is selected. Numbers are appended if name conflicts occur. - username [password | *] -- Specifies a user name and password with which to connect. If an asterisk is used, the user is prompted for the password, but does not display the characters typed. - /domain:domain -- Specifies the domain the user account is located in. - If not present, the last value of the Domain field in the Connect To dialog box is used. - /callback:callbacknumber -- Substitutes the specified callback number for the entry's callback number in Rasphone.pbk. - /disconnect -- Disconnects the specified entry. - /phonebook:phonebookpath -- Specifies the path to the phonebook file. The default is \systemroot\System32\Ras\username.pbk. Specifying a full path to the file is an option. - /prefixsuffix -- Applies the current TAPI location dialing settings to the phone number. These settings are configured in Telephony, which is located in Control Panel. This option is off by default. Examples: To connect to the OFFICE entry in Rasphone.pbk, type: rasdial office To connect to the OFFICE 2 entry in Rasphone.pbk and specify a callback number, type: rasdial "office 2" /callback:555-0100 To disconnect from the EAST OFFICE entry, type: rasdial "EAST OFFICE" /d
RD Removes (i.e. deletes) a directory. rd [Drive:]Path [/s] [/q] rmdir [Drive:]Path [/s] [/q] Parameters: - [Drive:]Path -- Specifies the location and name of the directory to delete. - /s -- Removes the specified directory and all subdirectories including any files. Use /s to remove a tree. - /q -- Runs rd in quiet mode. Deletes directories without confirmation. - /? -- Displays help at the command prompt. Remarks: Using rd at the Recovery Console: ==================================== The rd command, with different parameters, is available from the Recovery Console. Cannot delete directory with hidden or system files: ==================================================== rd will not delete a directory that contains files, including hidden or system files. Attempt to do so will display the following message: The directory not empty: Use the dir command to list hidden and system files, and the attrib command to remove hidden and system attributes from files. For more information, see Related Topics. Using the backslash character with the path parameter: ====================================================== If a backslash (\) is inserted before the first directory name in path, the directory is treated as a subdirectory of the root directory, regardless of the current directory. If a backslash is not inserted before the first directory name in path, the directory is treated as a subdirectory of the current directory. Deleting the current directory: =============================== rd cannot delete the current directory. That directory must be deleted after changing to a different directory (but not to a subdirectory of the current directory) and then use rd with a path. If attempting to delete the current directory, the following message appears: The process cannot access the file because it is being used by another process. Examples: To delete a directory named \User\Smith, first ensure that the directory is empty. To do this, type: dir \user\smith /a Only the "." and ".." symbols should display. Then, from any directory except \User\Smith, type: rd \user\smith To delete the directory \User and all of the subdirectories and files, type: rd /s \user
RECOVER Recovers readable information from a bad or defective disk. recover [Drive:][Path] FileName Parameters: - [Drive:][Path] FileName -- Specifies the location and name of the file to recover. - /? -- Displays help at the command prompt. Remarks: The recover command reads a file sector by sector and recovers data from the good sectors. Data in bad sectors is lost. Limitation on [drive:][path]filename: ===================================== Wildcards (* and ?) cannot be used with the recover command. A file must be specified. Reentering lost data: ===================== Because all data in bad sectors is lost when recovering a file, files should be recovered one at a time. Use this method to edit each file and reenter missing information after recovering the file. Recovering bad sectors: ======================= Bad sectors reported by chkdsk were marked as "bad" when the disk was first prepared for operation. They pose no danger, and recover does not affect them. Examples: To recover the file Story.txt in the \Fiction directory in drive D:, type: recover d:\fiction\story.txt
REDIRECTION Redirection operators can be used to redirect command input and output streams from the default locations to different locations. The input or output stream location is referred to as a handle The following lists operators that can be used to redirect command input and output streams. Redirection operator - Description > - Writes the command output to a file or a device, such as a printer, instead of the Command Prompt window. < - Reads the command input from a file, instead of reading input from the keyboard. >> - Appends the command output to the end of a file without deleting the information that is already in the file. >& - Writes the output from one handle to the input of another handle. <& - Reads the input from one handle and writes it to the output of another handle. | - Reads the output from one command and writes it to the input of another command. Also known as a pipe. By default, the command input (i.e. the STDIN handle) can be sent from the keyboard to Cmd.exe, and then Cmd.exe sends the command output (i.e. the STDOUT handle) to the Command Prompt window. The following table lists the available handles. Handle - Numeric equivalent of handle - Description STDIN - 0 - Keyboard input STDOUT - 1 - Output to the Command Prompt window STDERR - 2 - Error output to the Command Prompt window UNDEFINED - 3-9 - These handles are defined individually by the application and are specific to each tool. The numbers zero through nine (i.e. 0-9) represent the first 10 handles. Cmd.exe can be used to run a program and redirect any of the first 10 handles for the program. To specify which handle to use, type the number of the handle before the redirection operator. If a handle is not defined, the default < redirection input operator is zero (0) and the default > redirection output operator is one (1). After typing the < or > operator, specify where to read or write the data. Either a file name or another existing handle can be specified. To specify redirection to existing handles, use the ampersand (&) character followed by the handle number to redirect (i.e. &handle#). For example, the following command redirects handle 2 (i.e. STDERR) into handle 1 (i.e. STDOUT): 1<&2 Duplicating handles =================== The & redirection operator duplicates output or input from one specified handle to another specified handle. For example, to send dir output to File.txt and send the error output to File.txt, type: dir>c:\file.txt 2>&1 When duplicating a handle, duplicate all characteristics of the original occurrence of the handle. For example, if a handle has write-only access, all duplicates of that handle have write-only access. A handle cannot duplicate a handle with read-only access into a handle with write-only access. Redirecting command input (<) ============================= To redirect command input from the keyboard to a file or device, use the < operator. For example, to get the command input for the sort command from File.txt, type: sort) ============================== Almost all commands send output to the Command Prompt window. Even commands that send output to a drive or printer display messages and prompts in the Command Prompt window. To redirect command output from the Command Prompt window to a file or device, use the > operator. This operator can be used with most commands. For example, to redirect dir output to Dirlist.txt, type: dir>dirlist.txt If Dirlist.txt does not exist, Cmd.exe creates it. If Dirlist.txt exists, Cmd.exe replaces the information in the file with the output from the dir command. To run the netsh routing dump command and then send the command output to Route.cfg, type: netsh routing dump>c:\route.cfg The > operator opens the specified file with write-only access. As a result, the file cannot be read with this operator. For example, if start a program with redirection >&0, all attempts to write handle 1 fail because handle 0 is initially opened with read-only access. Note: One is the default handle for the > redirection output operator. Using the <& operator to redirect input and duplicate ===================================================== To use the redirection input operator <&, the file specified must already exist. If the input file exists, Cmd.exe opens it as read-only and sends the characters contained in the file as input to the command as if they were input from the keyboard. If a handle is specified, Cmd.exe duplicates the handle specified onto the existing handle in the system. For example, to open File.txt as input read to handle 0 (i.e. STDIN), type: search.txt 2<&1 To duplicate a user-defined handle 3 as input read to handle 0 (i.e. STDIN), type: <&3 Using the >& operator to redirect output and duplicate ====================================================== If output is redirected to a file and an existing file name is specified, Cmd.exe opens the file as write-only and overwrites the file's contents. If a handle is specified, Cmd.exe duplicates the file onto the existing handle. To duplicate a user-defined handle 3 into handle 1, type: >&3 To redirect all of the output, including handle 2 (i.e. STDERR), from the ipconfig command to handle 1 (i.e. STDOUT), and then redirect the ouput to Output.log, type: ipconfig.exe>>output.log 2>&1 Using the >> redirection operator to append output ================================================== To add the output from a command to the end of a file without losing any of the information already in the file, use two consecutive greater than signs (i.e. >>). For example, the following command appends the directory list produced by the dir command to the Dirlist.txt file: dir>>dirlist.txt To append the output of the netstat command to the end of Tcpinfo.txt, type: netstat>>tcpinfo.txt Using the pipe operator (|) =========================== The pipe operator (|) takes the output (by default, STDOUT) of one command and directs it into the input (by default, STDIN) of another command. For example, the following command sorts a directory: dir | sort In this example, both commands start simultaneously, but then the sort command pauses until it receives the dir command's output. The sort command uses the dir command's output as its input, and then sends its output to handle 1 (i.e. STDOUT). Combining commands with redirection operators ============================================= Custom commands can be created by combining filter commands with other commands and file names. For example, use the following command to store the names of files that contain the string "LOG": dir /b | find "LOG" > loglist.txt The dir command's output is sent through the find filter command. File names that contain the string "LOG" are stored as a list of file names (for example, NetshConfig.log, Logdat.svd, and Mylog.bat) in the Loglist.txt file. To use more than one filter in the same command, separate the filters with a pipe (|). For example, the following command searches every directory on drive C:, finds the file names that include the string "Log", and then displays them in one Command Prompt window at a time: dir c:\ /s /b | find "LOG" | more Use a pipe (|) to direct Cmd.exe to send the dir command output through the find filter command. The find command selects only file names that contain the string "LOG." The more command displays the file names that are selected by the find command, one Command Prompt window at a time. For more information about filter commands, see Using filters.
REG Add, change and display registry subkey information/values in registry entries reg add -- Adds a new subkey or entry to the registry reg add KeyName [/v EntryName|/ve] [/t DataType] [/s separator] [/d value] [/f] Parameters: - KeyName -- Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the format of \\ComputerName\PathToSubkey. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. - /v EntryName -- Specifies the name of the entry to be added under the specified subkey. - /ve -- Specifies that the entry that is added to the registry has a null value. - /t DataType -- Specifies the data type for the value of the entry. DataType can be one of the following: -- REG_SZ -- REG_MULTI_SZ -- REG_DWORD_BIG_ENDIAN -- REG_DWORD -- REG_BINARY -- REG_DWORD_LITTLE_ENDIAN -- REG_LINK -- REG_FULL_RESOURCE_DESCRIPTOR -- REG_EXPAND_SZ - /s separator -- Specifies the character used to separate multiple instances of data. Used when REG_MULTI_SZ is specified as the data type and more than one entry needs to be listed. If not specified, the default separator is \0. - /d value -- Specifies the value for the new registry entry. - /f -- Adds the subkey or entry without asking for confirmation. - /? -- Displays help at the command prompt. Remarks: Subtrees cannot be added with this operation. This version of Reg does not ask for confirmation when adding a subkey. The following table lists the return values for the reg add operation. Value - Description 0 - Success 1 - Failure Examples: - reg add \hklm\software\myco /v data /t reg_binary /d fe340ead - reg add "hkcu\software\microsoft\winmine" /v Name3 /t reg_sz /d Anonymous - reg add "hkcu\software\microsoft\winmine" /v Time3 /t reg_dword /d 5 reg compare -- Compares specified registry subkeys or entries. reg compare KeyName1 KeyName2 [/v EntryName | /ve] {[/oa]|[/od]|[/os]|[on]} [/s] Parameters: - KeyName -- Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the format of \\ComputerName\PathtoSubkey. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. If a remote computer is specified, use the HKLM and HKU subtrees only. - /v EntryName -- Compares a specific entry under the subkey. - /ve -- Specifies that only entries that have no value will be compared. - {[/oa]|[/od]|[/os]|[on]} -- Specifies how differences and matches are displayed. Default is /od. Value - Description /oa - Specifies that all differences and matches are displayed. By default, only the differences are listed. /od - Specifies that only differences are displayed. This is the default behavior. /os - Specifies that only matches are displayed. By default, only the differences will be listed. /on - Specifies that nothing is displayed. By default, only the differences will be listed. /s Separator -- Compares all subkeys and entries. /? - Displays help at the command prompt. Remarks: The following table lists the return values for the reg compare operation. Value - Description 0 - The comparison is successful and the result is identical. 1 - The comparison failed. 2 - The comparison is successful and differences were found. Examples: The following example shows how the reg compare command can be used: reg compare "hkcu\software\microsoft\winmine" "hkcu\software\microsoft\winmine" /od /s reg copy Copies a registry entry to a specified location in the local or remote computer. reg copy KeyName1 KeyName2 [/s] [/f] Parameters: - KeyName1 -- Specifies the full path of the subkey to copy. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, the HKLM and HKU subtrees only can be used. - KeyName2 -- Specifies the full path of the subkey destination. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, the HKLM and HKU subtrees only can be used. - /s -- Copies all subkeys and entries under the specified subkey. - /f -- Copies the subkey without asking for confirmation. - /? -- Displays help at the command prompt. Remarks: This version of Reg does not ask for confirmation when copying a subkey. The following table lists the return values for the reg copy operation. Value - Description 0 - Success 1 - Failure Examples: The following examples show how the reg copy command can be used: - reg copy "hkcu\software\microsoft\winmine" "hkcu\software\microsoft\winminebk" /s /f - reg copy "hkcu\software\microsoft\winminebk" "hkcu\software\microsoft\winmine" /s reg delete Deletes a subkey or entries from the registry. reg delete KeyName [{/v EntryName|/ve|/va}] [/f] Parameters: - KeyName -- Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. - /v EntryName -- Deletes a specific entry under the subkey. If no entry is specified, then all entries and subkeys under the subkey will be deleted. - /ve -- Specifies that only entries that have no value will be deleted. - /va -- Deletes all entries under the specified subkey. Subkeys under the specified subkey are not deleted with this parameter. - /f -- Deletes the existing registry subkey or entry without asking for confirmation. - /? -- Displays help at the command prompt. Remarks: The following table lists the return values for the reg delete operation. Value - Description 0 - Success 1 - Failure Examples: The following examples show how the reg delete command can be used: - reg delete "hkcu\software\microsoft\winmine" /v Name1 - reg delete "hkcu\software\microsoft\winmine" /v Time1 - reg delete "hkcu\software\microsoft\winmine" /va reg export Creates a copy of specified subkeys, entries and values into a file so that it can be transferred to other servers. reg export KeyName FileName Parameters: - KeyName -- Specifies the full path of the subkey. The export operation works only with the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. - FileName -- Specifies the name and path of the file to be exported. The file must have an extension of .reg - /? -- Displays help at the command prompt. Remarks: The following table lists the return values for the reg export operation. Value - Description 0 - Success 1 - Failure Examples: The following example shows how the reg export command can be used: - reg export "hkcu\software\microsoft\winmine" c:\data\regbackups\wmbkup.reg reg import Copies a file containing exported registry subkeys, entries and values into the local computer's registry. reg import FileName Parameters: - FileName -- Specifies he name and path of the file that will be copied into the registry of the local computer. This file needs to be created beforehand with the reg export operation. - /? -- Displays help at the command prompt. Remarks: The following table lists the return values for the reg import operation. Value - Description 0 - Success 1 - Failure Examples: The following example shows how the reg import command can be used: reg import "hkcu\software\microsoft\winmine" c:\data\regbackups\wmbkup.reg reg load Writes saved subkeys and entries back to a different subkey in the registry. This is intended to be a temporary file that can be used for troubleshooting or editing registry entries. reg load KeyName FileName Parameters: - KeyName -- Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. - FileName -- Specifies the name and path of the file that will be loaded. This file must have been created with the reg save operation using an extension of .hiv. - /? -- Displays help at the command prompt. Remarks: The following table lists the return values for the reg load operation. Value - Description 0 - Success 1 - Failure Examples: The following example shows how the reg load command can be used: reg load "hkcu\software\microsoft\winminebk2" wmbkup.hiv reg query Returns a list of the next tier of subkeys and entries located under a subkey in the registry. reg query KeyName [{/v EntryName|/ve}] [/s] Parameters: - KeyName -- Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. If a remote computer is specified, the HKLM and HKU subtrees only can be used. - /v EntryName -- Returns a specific entry and its value. This parameter only returns entries that are in the tier directly below the specified subkey. Entries that are located in subkeys under the current subkey will not be found. When EntryName is omitted, all entries under the subkey are returned. - /ve -- Specifies that only entries that have no value will be returned. - /s -- Returns all subkeys and entries in all tiers. Without this parameter, only the next tier of subkeys and entries will be returned. - /? -- Displays help at the command prompt. Remarks: The following table lists the return values for the reg query operation. Value - Description 0 - Success 1 - Failure Examples: The following examples show how the reg query command can be used: - reg query "hklm\system\currentcontrolset\control\session manager" /v maxstacktracedepth - reg query "hkcu\software\microsoft\winmine" /s reg restore Writes saved subkeys and entries back to the registry. reg restore KeyName FileName Parameters: - KeyName -- Specifies the full path of the subkey. The restore operation works only with the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. - FileName -- Specifies the name and path of the file that will be written back to the registry. This file needs to be created beforehand with the reg save operation using an extension of .hiv - /? -- Displays help at the command prompt. Remarks: This operation is used to overwrite registry entries that have been edited. Before editing entries, save the parent subkey with the reg save operation. If the edit fails, restore the subkey with this operation. The following table lists the return values for the reg restore operation. Value - Description 0 - Success 1 - Failure Examples: The following example shows how the reg restore command can be used: reg restore "hkcu\software\microsoft\winmine" wmbkup.hiv reg save Saves a copy of specified subkeys, entries and values of the registry in a specified file. reg save KeyName FileName Parameters: - KeyName -- Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. - FileName -- Specifies the name and path of the file that is created. If no path is specified, then the current path is used. - /? -- Displays help at the command prompt. Remarks: The following table lists the return values for the reg save operation. Value - Description 0 - Success 1 - Failure Examples: The following example shows how the reg restore command can be used: reg save "hkcu\software\microsoft\winmine" wmbkup.hiv reg unload Removes a section of the registry that was loaded using the reg load operation. reg unload KeyName Parameters: - KeyName -- Specifies the full path of the subkey. For remote computers, include the computer name before the path of the subkey in the \\ComputerName\PathToSubkey format. Omitting ComputerName causes the operation to default to the local computer. Start the path with the appropriate subtree. The valid subtrees are HKLM, HKCU, HKCR, HKU and HKCC. - /? -- Displays help at the command prompt. Remarks: The following table lists the return values for the reg unload operation. Value - Description 0 - Success 1 - Failure Examples: The following example shows how the reg restore command can be used: - reg unload "hkcu\software\microsoft\winminebk2" Caution: Incorrectly editing the registry may severely damage the system. Before making changes to the registry, back up any valued data on the computer. Caution: Do not edit the registry directly unless there are no alternative. The registry editor bypasses standard safeguards, allowing settings that can degrade performance, damage the system, or even require Windows to be reinstalled. It is best to safely alter most registry settings by using the programs in Control Panel or Microsoft Management Console (MMC). If the registry must be edited directly, back it up first. Read the Registry Editor Help for more information. Remarks: Using Reg directly edits the registry of local or remote computers. These changes can render the computers inoperable and cause the need for a new installation of the operating system. Instead of directly editing the registry, use Control Panel or Microsoft Management Console, whenever possible, to make changes to the registry. Some operations allow the viewing or configuration of registry entries on local or remote computers, while others allow only the configuration of local computers. Also, accessing the registry remotely might limit the parameters that are available in an operation. Check the syntax for each operation to verify that it can be used on remote computers and to verify the parameters that can be used in that situation.
REGEDIT View and edit the Windows System Registry regedit [/S\ [/e] [/c] [L:system /R:user] [/d] [reg file name] Parameters: - regfile -- import/merge a registry file with confirmation Note that if a key has a dash/hyphen before it (and after the open bracket) then that key/tree will be deleted instead of imported/merged. To remove a specific value, the dash or hyphen goes after the equals sign (see example below) - /s -- import/merge a registry file without any confirmation - /e -- export any portion (per the given key) of the Registry to a file - /c -- compress a registry file (available only in Win 98) - /d -- delete (available only in Win 95,98 and Me) - /L and /r -- specify location of the system.dat file and user.dat file (available only in Win 95,98 and Me) Examples: - regedit /s newregistrykey.req - regedit /e microsoft.txt HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft - regedit /L:c:\windows\system.dat /r:c:\windows\user.dat - regedit /d microsoft.txt HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft - regedit somefile.reg whose contents include: REGEDIT4 ; @ECHO OFF ; CLS ; REGEDIT.EXE /S "%~f0" ; EXIT [-HKEY_LOCAL_MACHINE\SOFTWARE\KeyToRemove] [HKEY_LOCAL_MACHINE\SOFTWARE\KeyRemoveOnlyOneString] "StringToBeRemoved"=- This will remove the entire key/tree "KeyToRemove" and it will remove the string for "StringToBeRemoved" leaving the rest of KeyRemoveOnlyOneString as it was. Note that the line "REGEDIT4" is required. The CLS will prevent any popup error messages. The EXIT is to get out of here if severe error occurs. The REGEDIT statement runs the comand and uses the "%~f0" like it does parameters in a batch command file.
REGSVR32 Registers .dll files as command components in the registry. regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname Parameters: - /u -- Unregisters server. - /s -- Specifies regsvr32 to run silently and to not display any message boxes. - /n -- Specifies not to call DllRegisterServer, this must be used with option /i. - /i:cmdline -- Calls DllInstall passing it an optional [cmdline]. When used with /u it calls dll uninstall. - dllname -- Specifies the name of the dll file that will be registered. - /? -- Displays help at the command prompt. Examples: To register the .dll for the Active Directory Schema, type: regsvr32 schmmgmt.dll
REM Enables comments/remarks to be included in batch files and configuration files rem [comment] Parameters: - comment -- Specifies any string of characters to include as a comment. /? -- Displays help at the command prompt. Remarks: Using the echo command to display comments: The rem command does not display comments on the screen. The echo on command in a batch or Config.nt file is used to display comments. Restrictions on batch file comments: A redirection character "(" or ")" or pipe (|) cannot be used in a batch file comment. Using rem to add vertical spacing: Although the rem without a comment can be used to add vertical spacing to a batch file, blank lines can also be used. The blank lines are ignored when processing the batch program. Examples: The following example shows a batch file that uses remarks for both explanations and vertical spacing: @echo off rem This batch program formats and checks new disks. rem It is named Checknew.bat. rem echo Insert new disk in drive B. pause format b: /v chkdsk b: To include an explanatory comment in the Config.nt file before the prompt command, add the following lines to Config.nt: rem Set prompt to indicate current directory prompt $p$g
REN Changes the name of a file or a set of files. REN [drive:][path]filename1 filename2 RENAME [drive:][path]filename1 filename2 Parameters: - [Drive:][Path] filename1 -- Specifies the location and name of the file or set of files to rename. - filename2 -- Specifies the new name for the file. Wildcards (* and ?) are used, filename2 specifies the new names for the files. A new drive or path cannot be specified when renaming files. - /? -- Displays help at the command prompt. Remarks: Renaming files: =============== All files matching the specified file name can be renamed. The rename command cannot be used to rename files across drives or to move files to a different directory location. Using wildcards with rename: ============================ Wildcards (* and ?) can be used in either file name parameter. If wildcards are used in filename2, the characters represented by the wildcards will be identical to the corresponding characters in filename1. Rename will not work if filename2 already exists If, for filename2, a file name that already exists is specified, rename displays the following message: Duplicate file name or file not found Examples: To change the extensions of all the file names in the current directory that, for example, have the extension .txt to .doc extensions, type: ren *.txt *.doc To rename a file or directory named Chap10 to Part10, type: ren chap10 part10 To remove a prefix from a group of file names, type such as: ren "xxxx*.*" "////*.*" where "xxxx" is the prefix to remove from the file names and "////" are one-for-one placeholders for the prefix characters to be removed from the file names Example: file names have prefix "abcdef" thus type: ren "abcdef*.* "//////*.*" To add a prefix (e.g. "abc") to a group of file names, type such as: for %a in (*.*) do ren "%a" "abc%a"
RENAME
Renames a file or files.
See REN
REPLACE Replaces files in the destination directory with files in the source directory that have the same name. replace [drive1:][path1] FileName [drive2:][path2] [/a] [/p] [/r] [/w] replace [drive1:][path1] FileName [drive2:][path2] [/p] [/r] [/s] [/w] [/u] Parameters: - [drive1:][path1] FileName -- Specifies the location and name of the source file or set of files. - [drive2:][path2] -- Specifies the location of the destination file. A file name cannot be specified for replaced files. If neither a drive nor a directory is specified, replace uses the current drive and directory as the destination. - /a -- Adds new files to the destination directory instead of replacing existing files. This command-line option cannot be used with the /s or /u command-line option. - /p -- Prompts for confirmation before replacing a destination file or adding a source file. - /r -- Replaces read-only files as well as unprotected files. If this command-line option is not specified but attempts to replace a read-only file, an error results and stops the replacement operation. - /w -- Waits for a disk to be inserted before replace begins to search for source files. If /w is not specified, replace begins replacing or adding files immediately after pressing ENTER. - /s -- Searches all subdirectories of the destination directory and replaces matching files. The /s command-line option cannot be used with the /a command-line option. The replace command does not search subdirectories specified in path1. - /u -- Replaces (updates) only those files on the destination directory that are older than those in the source directory. The /u command-line option cannot be used with the /a command-line option. - /? -- Displays help at the command prompt. Remarks: replace can be used to add unique file names to the destination directory. Replace messages ================= As replace adds or replaces files, the file names are displayed on the screen. After the replace command is finished, a summary line is displayed in one of the following formats: nnn files added nnn files replaced no file added no file replaced Replacing files on floppy disks ================================ If using floppy disks and need to switch disks during the replace operation, specify the /w command-line option so that replace will wait for switching disks, as necessary. Limitations on replace The replace command cannot be used to update hidden files or system files. For information about changing hidden and system attributes, click attrib in the Related Topics list. Replace exit codes =================== The following list shows each exit code and a brief description of its meaning: Exit code - Description 0 - The replace command successfully replaced or added the files. 1 - The replace command encountered an incorrect version of MS-DOS. 2 - The replace command could not find the source files. 3 - The replace command could not find the source or destination path. 5 - The user does not have access to the files to replace. 8 - There is insufficient system memory to carry out the command. 11 - The user used the wrong syntax on the command line. The errorlevel parameter can be used on the if command line in a batch program to process exit codes returned by replace. For an example of a batch program that processes exit codes, click if in the Related Topics list. Examples: Suppose that several directories on drive C contain different versions of a file named Phones.cli, which contains client names and phone numbers. To replace all of these files with the latest version of the Phones.cli file from the disk in drive A, type: replace a:\phones.cli c:\ /s To add new printer device drivers to a directory on drive C named Tools, which already contains several printer device-driver files for a word processor: replace a:*.prd c:\tools /a This command searches the current directory on drive A for any files that have the extension .prd and then adds these files to the Tools directory on drive C. Because the /a command-line option is included, replace adds only those files from drive A that do not exist on drive C.
RMDIR
Removes (deletes) a directory.
See RD
RUNAS Allows a user to run specific tools and programs with different permissions than the user's current logon provides. runas [{/profile|/noprofile}] [/env] [/netonly] [/smartcard] [/showtrustlevels] [/trustlevel] /user:UserAccountName program Parameters: - /profile -- Loads the user's profile. /profile is the default. - /no profile -- Specifies that the user's profile is not to be loaded. This allows the application to load more quickly, but it can also cause a malfunction in some applications. - /env -- Specifies that the current network environment be used instead of the user's local environment. - /netonly -- Indicates that the user information specified is for remote access only. - /smartcard -- Indicates whether the credentials are to be supplied from a smartcard. - /showtrustlevels -- Lists the /trustlevel options. - /trustlevel -- Specifies the level of authorization at which the application is to run. Use /showtrustlevels to see the trust levels available. - /user:UserAccountName -- Specifies the name of the user account under which to run the program. The user account format should be user@domain or \Domain\User. - program -- Specifies the program or command to run using the account specified in /user. - /? -- Displays help at the command prompt. Remarks: It is good practice for administrators to use an account with restrictive permissions to perform routine, nonadministrative tasks, and to use an account with broader permissions only when performing specific administrative tasks. To accomplish this without logging off and back on, log on with a regular user account, and then use the runas command to run the tools that require the broader permissions. For examples of the use of the runas command, see Related Topics. The use of runas is not restricted to administrator accounts, although that is the most common use. Any user with multiple accounts can use runas to run a program, MMC console, or Control Panel item with alternate credentials. To use the Administrator account for the /user: parameter, type one of the following: - /user:AdministratorAccountName@ComputerName - /user:ComputerName\AdministratorAccountName To use this command as a domain administrator, type one of the following: - /user:AdministratorAccountName@DomainName - /user:DomainName\AdministratorAccountName Runas allows running programs (*.exe), saved MMC consoles (*.msc), shortcuts to programs and saved MMC consoles, and Control Panel items. These can be run as an administrator while logged onto the PC as a member of another group, such as the Users or Power Users group. Runas can start any program, MMC console, or Control Panel item. As long appropriate user account and password information are provided, the user account has the ability to log on to the computer, and the program, MMC console, or Control Panel item is available on the system and to the user account. The runas command allows administering a server in another forest (i.e. the local computer running a tool and the server being administered are in different domains). When starting a program, MMC console, or Control Panel item from a network location using runas, it might fail because the credentials used to connect to the network share are different from the credentials used to start the program. The latter credentials may not be able to gain access to the same network share. Some items, such as the Printers folder and desktop items, are opened indirectly and cannot be started with the runas command. If the runas command fails, the Secondary Logon service might not be running or the user account being used might not be valid. To check the status of the Secondary Logon service, in Computer Management, click Services and Applications, and then click Services. To test the user account, try logging on to the appropriate domain using the account. Examples: To start an instance of the command prompt as an administrator on the local computer, type: - runas /user:localmachinename\administrator cmd When prompted, type the administrator password. To start an instance of the Computer Management snap-in using a domain administrator account called companydomain\domainadmin, type: runas /user:companydomain\domainadmin "mmc %windir%\system32\compmgmt.msc" When prompted, type the account password. To start an instance of Notepad using a domain administrator account called user in a domain called domain.microsoft.com, type: runas /user:user@domain.microsoft.com "notepad my_file.txt" When prompted, type the account password. To start an instance of a command prompt window, saved MMC console, Control Panel item, or program that will administer a server in another forest, type: - runas /netonly /user:domain\username "command" domain\username must be a user with sufficient permissions to administer the server. When prompted, type the account password.
Scanner/Camera Settings
This is a short cut to start up the SCANNER/CAMERA Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
SCICPL.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
SCHTASKS
Manage Windows scheduled tasks using the command prompt
This is a HUGE topic, more than is necessary to put here. See
http://www.microsoft.com
/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
for a detailed write up about this if it is really necessary.
Otherwise, it is much easier to use the GUI interface found under the
Control Panel > Scheduled Tasks
Security Policy
This is a short cut to start up the Local Security Policy dialog portion of the
Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
secpol.msc and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Windows Services
This is a short cut to start up the Windows Services Management dialog.
Either make a shortcut on the desktop with this or do START then RUN then type in
SERVICES.MSC and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
SET
Displays, sets, or removes cmd.exe environment variables.
SET [variable=[string]]
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:
SET command invoked with just a variable name, no equal sign or value
will display the value of all variables whose prefix matches the name
given to the SET command. For example:
SET P
would display all variables that begin with the letter 'P'
SET command will set the ERRORLEVEL to 1 if the variable name is not
found in the current environment.
SET command will not allow an equal sign to be part of the name of
a variable.
Two new switches have been added to the SET command:
SET /A expression
SET /P variable=[promptString]
The /A switch specifies that the string to the right of the equal sign
is a numerical expression that is evaluated. The expression evaluator
is pretty simple and supports the following operations, in decreasing
order of precedence:
() - grouping
! ~ - - unary operators
* / % - arithmetic operators
+ - - arithmetic operators
<< >> - logical shift
& - bitwise and
^ - bitwise exclusive or
| - bitwise or
= *= /= %= += -= - assignment
&= ^= |= <<= >>=
, - expression separator
If any of the logical or modulus operators are used, enclose the expression
string in quotes. Any non-numeric strings in the expression are treated as
environment variable names whose values are converted to numbers before
using them. If an environment variable name is specified but is not defined
in the current environment, then a value of zero is used. This allows
arithmetic to be done with environment variable values without having to type
all those % signs to get their values. If SET /A is executed from the command
line outside of a command script, then it displays the final value of the
expression. The assignment operator requires an environment variable name
to the left of the assignment operator. Numeric values are decimal numbers,
unless prefixed by 0x for hexadecimal numbers, and 0 for octal numbers.
So 0x12 is the same as 18 is the same as 022. Please note that the octal
notation can be confusing: 08 and 09 are not valid numbers because 8 and
9 are not valid octal digits.
The /P switch allows a line of input entered by the user to be set as the
value of a variable. Displays the specified promptString before reading
the line of input. The promptString can be empty.
Environment variable substitution has been enhanced as follows:
%PATH:str1=str2%
would expand the PATH environment variable, substituting each occurrence
of "str1" in the expanded result with "str2". "str2" can be the empty
string to effectively delete all occurrences of "str1" from the expanded
output. "str1" can begin with an asterisk, in which case it will match
everything from the beginning of the expanded output to the first
occurrence of the remaining portion of str1.
May also specify substrings for an expansion.
%PATH:~10,5%
would expand the PATH environment variable, and then use only the 5
characters that begin at the 11th (offset 10) character of the expanded
result. If the length is not specified, then it defaults to the
remainder of the variable value. If either number (offset or length) is
negative, then the number used is the length of the environment variable
value added to the offset or length specified.
%PATH:~-10%
would extract the last 10 characters of the PATH variable.
%PATH:~0,-2%
would extract all but the last 2 characters of the PATH variable.
Finally, support for delayed environment variable expansion has been
added. This support is always disabled by default, but may be
enabled/disabled via the /V command line switch to CMD.EXE. See CMD /?
Delayed environment variable expansion is useful for getting around
the limitations of the current expansion which happens when a line
of text is read, not when it is executed. The following example
demonstrates the problem with immediate variable expansion:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "%VAR%" == "after" @echo If this is seen, then it worked
)
would never display the message, since the %VAR% in BOTH IF statements
is substituted when the first IF statement is read, since it logically
includes the body of the IF, which is a compound statement. So the
IF inside the compound statement is really comparing "before" with
"after" which will never be equal. Similarly, the following example
will not work as expected:
set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%
in that it will NOT build up a list of files in the current directory,
but instead will just set the LIST variable to the last file found.
Again, this is because the %LIST% is expanded just once when the
FOR statement is read, and at that time the LIST variable is empty.
So the actual FOR loop we are executing is:
for %i in (*) do set LIST= %i
which just keeps setting LIST to the last file found.
Delayed environment variable expansion allows the use of a different
character (the exclamation mark) to expand environment variables at
execution time. If delayed variable expansion is enabled, the above
examples could be written as follows to work as intended:
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo If this is seen, then it worked
)
set LIST=
for %i in (*) do set LIST=!LIST! %i
echo %LIST%
If Command Extensions are enabled, then there are several dynamic
environment variables that can be expanded but which do not show up in
the list of variables displayed by SET. These variable values are
computed dynamically each time the value of the variable is expanded.
If the user explicitly defines a variable with one of these names, then
that definition will override the dynamic one described below:
%CD% - expands to the current directory string.
%DATE% - expands to current date using same format as DATE command.
%TIME% - expands to current time using same format as TIME command.
%RANDOM% - expands to a random decimal number between 0 and 32767.
%ERRORLEVEL% - expands to the current ERRORLEVEL value
%CMDEXTVERSION% - expands to the current Command Processor Extensions
version number.
%CMDCMDLINE% - expands to the original command line that invoked the
Command Processor.
SETLOCAL Starts localization of environment variables in a batch file. Localization continues until a matching endlocal command is encountered or the end of the batch file is reached. setlocal {enableextensions | disableextensions} {enabledelayedexpansion | disabledelayedexpansion} Parameters: - enableextensions -- Enables the command extensions until the matching endlocal command is encountered, regardless of the setting prior to the setlocal command. - disableextensions -- Disables the command extensions until the matching endlocal command is encountered, regardless of the setting prior to the setlocal command. - enabledelayedexpansion -- Enables the delayed environment variable expansion until the matching endlocal command is encountered, regardless of the setting prior to the setlocal command. - disabledelayedexpansion -- Disables the delayed environment variable expansion until the matching endlocal command is encountered, regardless of the setting prior to the setlocal command. - /? -- Displays help at the command prompt. Remarks: Using setlocal: When setlocal is used outside of a script or batch file, it has no effect. Changing environmental variables: Use setlocal to change environment variables when running a batch file. Environment changes made after setlocal is run are local to the batch file. Cmd.exe restores previous settings when it either encounters an endlocal command or reaches the end of the batch file. More than one setlocal or endlocal command in a batch program (i.e. nested commands) can be used. Testing for command extensions in batch files: The setlocal command sets the ERRORLEVEL variable. If either {enableextensions | disableextensions} or {enabledelayedexpansion | disabledelayedexpansion} are passed, the ERRORLEVEL variable is set to zero (0). Otherwise, it is set to one (1). This can be used in batch scripts to determine whether the extensions are available, for example: verify other 2>nul setlocal enableextensions if errorlevel 1 echo Unable to enable extensions Because cmd does not set the ERRORLEVEL variable when command extensions are disabled, the verify command initializes the ERRORLEVEL variable to a nonzero value when used with an invalid argument. Also, if the setlocal command is used with arguments {enableextensions | disableextensions} or {enabledelayedexpansion | disabledelayedexpansion} and it does not set the ERRORLEVEL variable to one (1), command extensions are not available. For more information about enabling and disabling command extensions, see cmd in Related Topics. Examples: Localize environment variables can be used in a batch file, as follows: rem *******Begin Comment************** rem This program starts the superapp batch program on the network, rem directs the output to a file, and displays the file rem in Notepad. rem *******End Comment************** @echo off setlocal path=g:\programs\superapp;%path% call superapp>c:\superapp.out endlocal start notepad c:\superapp.out
SFC: System File Checker Validate that the Windows files are the valid ones from Microsoft Sfc [/Scannow] [/Scanonce] [/Scanboot] [/Revert] [/Purgecache] [/Cachesize=x] Parameters: - /Scannow -- Scans all protected system files immediately and replaces incorrect versions with correct Microsoft versions. This command may require access to the Windows installation source files. - /Scanonce -- Scans all protected system files one time when the computer is restarted. This command may require access to the Windows installation source files when the computer is restarted. The SfcScan DWORD value is set to 2 in the following registry key when this command is run: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon - /Scanboot -- Scans all protected system files every time the computer is restarted. This command may require access to the Windows installation source files every time the computer is retarted. The SfcScan DWORD value is set to 1 in the following registry key when this command is rn: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon - /Revert -- Returns scan to the default setting (do not scan protected files when the computer is restarted).The default cache size is not reset when this command is run. This command is equivalent to the /Enable switch in Windows 2000. - /Purgecache -- Purges the file cache and scans all protected system files immediately. This command may require access to the Windows installation source files. - /Cachesize=x -- Sets the file cache size to x megabytes (MB). The default size of the cache is 50 MB. This command requires the computer to be restarted, and then run the /purgecache command to adjust the size of the on-disk cache. This command sets the SfcQuota DWORD value to x in the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon Remarks: System File Checker gives an administrator the ability to scan all protected files to verify their versions. If System File Checker discovers that a protected file has been overwritten, it retrieves the correct version of the file from the cache folder (%Systemroot%\System32\Dllcache) or the Windows installation source files, and then replaces the incorrect file. System File Checker also checks and repopulates the cache folder. Only a member of the Administrators group can run System File Checker. If the cache folder becomes damaged or unusable, use the sfc /scannow, the sfc /scanonce, or the sfc /scanboot commands to repair its contents.
SHADOW Remotely monitor and control another user's Terminal Services session. {session_name | session_id} [/server:server_name] [/v] Parameters: - session_name -- Use this parameter to specify the name of the session to remotely control. - session_id -- Use this parameter to specify the identification number (ID) of the session to remotely control. - /server:server_name -- Use this parameter to specify the Terminal server that contains the session to remotely control. By default, the current Terminal server is used. - /v -- Use this parameter to display information about the actions that are being performed. Remarks: The shadow command can be used to view or actively control an active session of another user. If actively controlling a user's session, input keyboard and mouse actions can be used for that session. Sessions (except for the current session) on the local PC can be remotely controlled. To do so, Full Control access permissions to remotely control another session must be available. The local session must be able to support the video resolution that is used for the session being remotely controlled. If the session cannot support the video resolution of this session, the other session cannot remotely controlled. While in this console session, another session cannot be remotely controlled and the session cannot be remotely controlled by another session. The remote control functionality can be used to observe or actively control another session. How to Configure Remote Control Settings: ========================================= To configure remote control for users and sessions, use either Terminal Services Configuration or the Terminal Services extensions to Local Users and Groups and the Terminal Services extensions to Active Directory for Users and Computers. To configure remote control settings: - Click Start, point to Programs, point to Administrative Tools, and then click Terminal Services Configuration. - In the console tree, click Connections. - Right-click the connection to configure remote control in the details pane, and then click Properties. - Click the Remote Control tab, and then click Use remote control with the following settings to configure remote control for the connection. - To configure remote control so that a message is displayed on the client computer that prompts the user for permission to view or take part in the session, click to select the Require user's permission check box. - Under Level of control, click either of the following options: -- View the session: Click this option to specify that the user's session can be viewed only. -- Interact with the session: Click this option to specify that the user's session can be actively controlled with the keyboard and mouse. Troubleshooting: ================ - The following error message can be received: Remote control failed. Error code 7044 Error [7044]:The request to control another session remotely was denied. This message occurs if either there is no response from the computer that is to be monitored or if the request is refused. Before monitoring begins, the server prompts the user that the session is about to be remotely controlled, (unless this warning is turned off). The user of the computer that is to be monitored receives the following message: \\server\tester is requesting to control the session remotely. Do you accept the request? Click Yes on the computer that is to be monitored to allow the session to be monitored. For more information about how to configure remote control settings, see the Configure Remote Control Settings section of this article. - If the shadow command is run from the console session, the following error message may be received: Remote control failed. Error code 7050 Error [7050]:The requested session cannot be controlled remotely. This may be because the session is disconnected or does not currently have a user logged on. This error message occurs because another session cannot be remotely controlled while in this console session and the session cannot be remotely controlled by another session. Examples: - To display a list of sessions and their session IDs, type query user at the command line on the server, and then press ENTER. The following output is displayed: USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME tester console 0 Active . 3/26/2011 11:17 AM >tester rdp-tcp#3 1 Active . 3/26/2011 4:02 PM tester rdp-tcp#6 2 Active 12 3/27/2011 8:44 AM - To shadow session 2, type shadow 2. - To shadow the session rdp-tcp#3, type shadow rdp-tcp#3. - Before monitoring another session, the user of the other session receives the following message (unless this warning is disabled): \\server\tester is requesting to control the session remotely. Do you accept the request? The session may stop responding (hang) for a few seconds while the server waits for a response from the user. - Press CTRL+* to end the remotely controlled session (use the asterisk [*] from the numeric keypad only). - A hot key can be defined in Terminal Services Manager to end the remotely controlled session.
SHIFT Changes the position of batch parameters in a batch file shift [/n] Parameters: - /n -- start shifting at the nth argument, n is between zero and eight Remarks: Using the shift command-line option with command extensions When command extensions are enabled (i.e. the default), the shift command supports the /n command-line option, which tells the command to start shifting at the nth argument, where n can be a value from zero to eight. For example, SHIFT /2 would shift %3 to %2, %4 to %3, and so on, and leave %0 and %1 unaffected. How the shift command works The shift command changes the values of the batch parameters %0 through %9 by copying each parameter into the previous one. In other words, the value of %1 is copied to %0, the value of %2 is copied to %1, and so on. This is useful for writing a batch file that performs the same operation on any number of parameters. Working with more than ten batch parameters Shift can be used to create a batch file that can accept more than ten batch parameters. If more than ten parameters are specified on the command line, those that appear after the tenth (%9) will be shifted one at a time into %9. Using %* with shift Shift has no affect on the %* batch parameter. Shifting parameters back There is no backward shift command. After the shift command is run, the first batch parameter (%0) that existed before the shift is lost. Examples: The following batch file, Mycopy.bat, shows how to use shift with any number of batch parameters. It copies a list of files to a specific directory. The batch parameters are represented by the directory and file name arguments. @echo off rem MYCOPY.BAT copies any number of files rem to a directory. rem The command uses the following syntax: rem mycopy dir file1 file2 ... set todir=%1 :getfile shift if "%1"=="" goto end copy %1 %todir% goto getfile :end set todir= echo All done The following would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 unaffected. SHIFT /2
SHUTDOWN Shut down or restart a local or remote computer. shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t xx] [-c "message"] [-d[u][p]:xx:yy] Parameters: - -l -- Logs off the current user, this is also the defualt. -m ComputerName takes precedence. - -s -- Shuts down the local computer. - -r -- Reboots after shutdown. - -a -- Aborts shutdown. Ignores other parameters, except -l and ComputerName. This parameter can only be used during the time-out period. - -f -- Forces running applications to close. - -m [\\ComputerName] -- Specifies the computer to shut down. - -t xx -- Sets the timer for system shutdown in xx seconds. The default is 20 seconds. - -c "message" -- Specifies a message (enclosed in quotes)) to be displayed (max 127 characters) in the Message area of the System Shutdown window. - -d [u][p]:xx:yy -- Lists the reason code for the shutdown. The following table lists the different values. Value - Description u - Indicates a user code. p - Indicates a planned shutdown code. xx - Specifies the major reason code (0-255). yy - Specifies the minor reason code (0-65536). - /? -- Displays help at the command prompt. Remarks: No parameters will logoff the current user. To use major and minor reason codes, they must first be defined on each computer that needs the particular reason. If the reason codes are not defined on the target computer, Event Viewer cannot log the correct reason text. Examples: To shut down \\MyServer in 60 seconds, force running applications to close, restart the computer after shutdown, indicate a user code, indicate that the shutdown is planned, log major reason code 125, and log minor reason code 1, type: shutdown -r -f -m \\MyServer -t 60 -d up:125:1
SORT Reads input, sorts data, and writes the results to the screen, to a file, or to another device sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec characters] [[drive1:][path1]filename1] [/t [drive2:][path2]] [/o [drive3:][path3]filename3] [command |] sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec characters] [[drive1:][path1]filename1][/t [drive2:][path2]] [/o [drive3:][path3]filename3] Parameters: - /r -- Reverses the sort order (i.e. sorts from Z to A, and then from 9 to 0). - /+n -- Specifies the character position number, n, at which sort begins each comparison. - /m kilobytes -- Specifies the amount of main memory to use for the sort, in kilobytes (KB). - /l locale -- Overrides the sort order of characters defined by the system default locale (i.e. the language and Country/Region selected during installation). - /rec characters -- Specifies the maximum number of characters in a record, or a line of the input file (the default is 4,096, and the maximum is 65,535). - [drive1:][path1]filename1 -- Specifies the file to be sorted. If no file name is specified, the standard input is sorted. Specifying the input file is faster than redirecting the same file as standard input. - /t [drive2:][path2] -- Specifies the path of the directory to hold the sort command's working storage, in case the data does not fit in main memory. The default is to use the system temporary directory. - /o [drive3:][path3]filename3 -- Specifies the file where the sorted input is to be stored. If not specified, the data is written to the standard output. Specifying the output file is faster than redirecting standard output to the same file. - /? -- Displays help at the command prompt. Remarks: Using the /+n command-line option: ================================== In using the /+n command-line option, for example, /+3 indicates that each comparison should begin at the third character in each line. Lines with fewer than n characters collate before other lines. By default, comparisons start at the first character in each line. Using the /m kilobytes command-line option: =========================================== The memory used is always a minimum of 160 KB. If the memory size is specified, the exact specified amount (but at least 160 KB) is used for the sort, regardless of how much main memory is available. The default maximum memory size when no size is specified is 90 percent of available main memory if both the input and output are files, and 45 percent of main memory otherwise. The default setting usually gives the best performance. Using the /l locale command-line option: ======================================== Currently, the only alternative to the default locale is the "C" locale, which is faster than natural language sorting and sorts characters according to their binary encodings. Specifying a source: ==================== Unless the command or FileName parameter is specified, sort acts as a filter and takes input from the standard input (i.e. usually from the keyboard, from a pipe, or from a file). Using redirection symbols with sort: ==================================== The pipe (|) symbol can be used to direct data through the sort command from another command, or to direct the sort output to another command (for example, to the more command to display information one screen at a time). Using the less than symbol (<) or greater than symbol (>) to specify the input file or output file may not be very efficient; instead, specify the input file directly (as defined in the command syntax) and specify the output file using the /o parameter. This can be much faster, particularly with large files. Uppercase vs. lowercase: ======================== The sort command does not distinguish between uppercase and lowercase letters. Limits on file size: ==================== The sort command has no limit on file size. Collating sequence: =================== The sort program uses the collating-sequence table that corresponds to the Country/Region code and code-page settings. Characters greater than ASCII code 127 are sorted based on information in the Country.sys file or in an alternate file specified by the country command in the Config.nt file. Memory usage: ============= If the sort fits in memory (i.e. either the default maximum memory size or as specified by the /m parameter), the sort is performed in one pass. Otherwise, the sort is performed in two passes, such that the amounts of memory used for both the sort and merge passes are equal. When two passes are performed, the partially sorted data is stored in a temporary file on disk. If there is not enough memory to perform the sort in two passes, a run-time error is issued. If the /m command-line option is used to specify more memory than is truly available, performance degradation or a run-time error can occur. Examples: Sorting a file: =============== The following command reads the file Expenses.txt, sorts it in reverse order, and displays it on the screen: sort /r expenses.txt Sorting the output from a command: ================================== To search a large file named Maillist.txt for the text "Jones," and to sort the results of the search, use the pipe (|) to direct the output of a find command to the sort command, as follows: find "Jones" maillist.txt | sort The command produces a sorted list of lines that contain the specified text. Sorting keyboard input: ======================= To sort keyboard input and display the results alphabetically on the screen, first use the sort command with no parameters, as follows: sort Then type the text to be sorted, pressing ENTER at the end of each line. When finished typing text, press CTRL+Z, and then press ENTER. The sort command displays the typed text, sorted alphabetically. Sorted keyboard input can also be redirected to a file. For more information, click redirect in the Related Topics list.
Sound/Audio Devices
This is a short cut to start up the Volume, Sound and Audio Devices dialog portion
of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
mmsys.cpl and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
START Starts a separate window to run a specified program or command. Starts a separate Command Prompt window to run a specified program or command. start ["title"] [/dPath] [/i] [/min] [/max] [{/separate | /shared}] [{/low | /normal | /high | /realtime | /abovenormal | belownormal}] [/wait] [/b] [FileName] [parameters] Parameters: - "title" -- Specifies the title to display in Command Prompt window title bar. - /dPath -- Specifies the startup directory. - /i -- Passes the Cmd.exe startup environment to the new Command Prompt window. - /min -- Starts a new minimized Command Prompt window. - /max -- Starts a new maximized Command Prompt window. - /separate -- Starts 16-bit programs in a separate memory space. - /shared -- Starts 16-bit programs in a shared memory space. - /low -- Starts an application in the idle priority class. - /normal -- Starts an application in the normal priority class. - /high -- Starts an application in the high priority class. - /realtime -- Starts an application in the realtime priority class. - /abovenormal -- Starts an application in the abovenormal priority class. - /belownormal -- Starts an application in the belownormal priority class. - /wait -- Starts an application and waits for it to end. - /b -- Starts an application without opening a new Command Prompt window. CTRL+C handling is ignored unless the application enables CTRL+C processing. Use CTRL+BREAK to interrupt the application. - FileName -- Specifies the command or program to start. - parameters -- Specifies parameters to pass to the command or program. Remarks: Used without parameters, start opens a second command prompt window. Non-executable files can be run through their file association by typing the name of the file as a command. For more information about creating these associations in a command script by using assoc and ftype, see Related Topics. When runing a command that contains a the string "CMD" as the first token without an extension or path qualifier, "CMD" is replaced with the value of the COMSPEC variable. This prevents users from picking up cmd from the current directory. When running a 32-bit graphical user interface (GUI) application, cmd does not wait for the application to quit before returning to the command prompt. This new behavior does not occur if running the application from a command script. When running a command that uses a first token that does not contain an 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 for the PATHEXT variable is: .COM;.EXE;.BAT;.CMD (i.e., the syntax is the same as the PATH variable, with semicolons separating the different elements). When searching for an executable and there is no match on any extension, start searches directory name. If it does, start opens Explorer.exe on that path. Examples: To start the Myapp program at the command prompt and retain use of the current Command Prompt window, type: start myapp
START Key plus some other Key
Using the START key
The START key held down then released will, of course, open up the Task Bar main START option.
Holding down the START key and striking another key causes another type of action to occur.
Only some keys struck while holding down the START key will do anything. They are:
- TAB or SHIFT-TAB -- visually scroll through the Task Bar list
- BREAK -- Display the System Properties dialog box
- E -- start up Windows Explorer
- R -- start up the RUN dialog
- U -- start up both the Utility Manager dialog and the Narrator dialog
- D -- toggle either minimizing everything on the desktop (including MS-Office Shortcut Bar if it is running) or maximizing all that it minimized
- F -- start up the FIND [in] FILES dialog
- F + CTRL -- Search for computers (on networks)
- L -- lock the keyboard and return the screen to the User logon
- M -- minimize everything on the desktop (except the Task Bar and MS-Office Shortcut Bar if it is running)
SUBST Associates a path with a drive letter. Used without parameters, subst displays the names of the virtual drives in effect. subst [drive1: [drive2:]Path] subst drive1: /d Parameters: - drive1: -- Specifies the virtual drive to assign a path. - drive2: -- Specifies the physical drive that contains the specified path (if different from the current drive). - Path -- Specifies the path to assign to a virtual drive. - /d -- Deletes a virtual drive. - /? -- Displays help at the command prompt. Remarks: The following commands do not work, or should not be used, on drives used in the subst command: chkdsk diskcomp diskcopy format label recover The drive1 parameter must be within the range specified by the lastdrive command. If not, subst displays the following error message: Invalid parameter - drive1: Examples: To create a virtual drive Z for the path B:\User\Betty\Forms, type: subst z: b:\user\betty\forms Now, instead of typing the full path, this directory can be reaced by typing the letter of the virtual drive, followed by a colon, as follows: z:
System Properties Settings
This is a short cut to start up the SSYSTEM PROPERTIES Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
SYSDM.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
System Files Editor
This is a short cut to start up the SYSTEM FILES EDITOR portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
SYSEDIT.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
SYSTEMINFO Displays detailed configuration information about a computer and its operating system, including operating system configuration, security information, product ID, and hardware properties, such as RAM, disk space, and network cards. systeminfo[.exe] [/s Computer [/u Domain\User [/p Password]]] [/fo {TABLE|LIST|CSV}] [/nh] Parameters: - /s Computer -- Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer. - /u Domain\User -- Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command. - /p Password -- Specifies the password of the user account that is specified in the /u parameter. - /fo {TABLE|LIST|CSV} -- Specifies the format to use for the output. Valid values are TABLE, LIST, and CSV. The default format for output is LIST. - /nh -- Suppresses column headers in the output. Valid when the /fo parameter is set to TABLE or CSV. - /? -- Displays help at the command prompt. Examples: The following examples show how to use the systeminfo command: - systeminfo.exe /s srvmain - systeminfo.exe /s srvmain /u maindom\hiropln - systeminfo /s srvmain /u maindom\hiropln /p p@ssW23 /fo table
TASKKILL Ends one or more tasks or processes. taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t] Parameters: - /s Computer -- Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer. - /u Domain\User -- Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command. - /p Password -- Specifies the password of the user account that is specified in the /u parameter. - /fi FilterName -- Specifies the types of process(es) to include in or exclude from termination. The following are valid filter names, operators and values. Name Operators Value ============== ======================== ==================================== Hostname eq, ne Any valid string. Status eq, ne RUNNING|NOT RESPONDING Imagename eq, ne Any valid string. PID eg, ne, gt, lt, ge, le Any valid positive integer. Session eg, ne, gt, lt, ge, le Any valid session number. CPUTime eq, ne, gt, lt, ge, le Valid time in the format of hh:mm:ss. The mm and ss parameters should be between 0 and 59 and hh can be any valid unsigned numeric value. Memusage eg, ne, gt, lt, ge, le Any valid integer. Username eq, ne Any valid user name ([Domain\]User). Services eq, ne Any valid string. Windowtitle eq, ne Any valid string. - /pid ProcessID -- Specifies the process ID of the process to be terminated. - /im ImageName -- Specifies the image name of the process to be terminated. Use the wildcard (*) to specify all image names. - /f -- Specifies that process(es) be forcefully terminated. This parameter is ignored for remote processes; all remote processes are forcefully terminated. - /t -- Specifies to terminate all child processes along with the parent process, commonly known as a tree kill. - /? -- Displays help at the command prompt. Remarks: Processes can be killed by process ID or image name. The wildcard character (*) is accepted only when specified along with the filters. Termination for remote processes will always be done forcefully regardless of whether the /f parameter is specified. Supplying a computer name to the HOSTNAME filter will cause a shutdown and all processes will be stopped. Use tasklist to determine the Process ID (PID) for the process to be terminated. Taskkill is a replacement for the Kill tool. Examples: - taskkill /pid 1230 /pid 1241 /pid 1253 - taskkill /f /fi "USERNAME eq NT AUTHORITY\SYSTEM" /im notepad.exe - taskkill /s srvmain /f /im notepad.exe - taskkill /s srvmain /u maindom\hiropln /p p@ssW23 /fi "IMAGENAME eq note*" /im * - taskkill /s srvmain /u maindom\hiropln /fi "USERNAME ne NT*" /im * - taskkill /f /fi "PID ge 1000" /im *
TASKLIST Displays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer. tasklist[.exe] [/s computer] [/u domain\user [/p password]] [/fo {TABLE|LIST|CSV}] [/nh] [/fi FilterName [/fi FilterName2 [ ... ]]] [/m [ModuleName] | /svc | /v] Parameters: /s Computer -- Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer. /u Domain\User -- Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command. /p Password -- Specifies the password of the user account that is specified in the /u parameter. /fo {TABLE|LIST|CSV} -- Specifies the format to use for the output. Valid values are TABLE, LIST, and CSV. The default format for output is TABLE. /nh -- Suppresses column headers in the output. Valid when the /fo parameter is set to TABLE or CSV. /fi FilterName -- Specifies the types of process(es) to include in or exclude from the query. The following table lists valid filter names, operators, and values. Name Operators Value ============== ======================== ==================================== Hostname eq, ne Any valid string. Status eq, ne RUNNING|NOT RESPONDING Imagename eq, ne Any valid string. PID eg, ne, gt, lt, ge, le Any valid positive integer. Session eg, ne, gt, lt, ge, le Any valid session number. SessionName eg, ne Any valid string. CPUTime eq, ne, gt, lt, ge, le Valid time in the format of hh:mm:ss. The mm and ss parameters should be between 0 and 59 and hh can be any valid unsigned numeric value. Memusage eg, ne, gt, lt, ge, le Any valid integer. Username eq, ne Any valid user name ([Domain\]User). Services eq, ne Any valid string. Windowtitle eq, ne Any valid string. Modules eq, ne Any valid string. /m [ModuleName] -- Specifies to show module information for each process. When a module is specified, all the processes using that module are shown. When a module is not specified, all the processes for all the modules are shown. This cannot be used with the /svc or the /v parameter. /svc -- Lists all the service information for each process without truncation. Valid when the /fo parameter is set to TABLE. Cannot be used with the /m or the /v parameter. /v -- Specifies that verbose task information be displayed in the output. Cannot be used with the /svc or the /m parameter. /? -- Displays help at the command prompt. RemarksL Tasklist is a replacement for the TList tool. Examples: - tasklist /v /fi "PID gt 1000" /fo csv - tasklist /fi "USERNAME ne NT AUTHORITY\SYSTEM" /fi "STATUS eq running" - tasklist /v /fi "STATUS eq running" - tasklist /s srvmain /nh - tasklist /s srvmain /s srvny - tasklist /s srvmain /u maindom\hiropln /p p@ssW23 /nh
TASKMGR
This is a short cut to start up the Windows Task Manager. Task Manager can control
the applications and processes that are running on the computer.
Either make a shortcut on the desktop with this or do START then RUN then type in
taskmgr and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Telephony Settings
This is a short cut to start up the TELEPHONY Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
TELEPHON.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
TELNET Communicate with a remote computer that is using the telnet protocol. telnet [\\RemoteServer] [Port] [/a] [/e] [/f] [/l] [/t] Remarks: Telnet can be run without parameters in order to enter the telnet context, indicated by the telnet prompt (telnet>). From the telnet prompt, use the following commands to manage a computer running Telnet Client. The tlntadmn commands allows remote management of a computer running Telnet Server. These commands are run from the command prompt. Used without parameters, tlntadmn displays local server settings. To use telnet commands at the telnet prompt To start Telnet Client and to enter the telnet prompt telnet [\\RemoteServer] Parameters: - \\RemoteServer -- Specifies the name of the server to which to connect. - Port -- Specifies the port number to which to connect. - /a -- Attempt automatic logon. Same as -l option except uses the currently logged on user's name. - /e -- Escape character to enter telnet client prompt. - /f -- File name for client side logging - /l -- Specifies the user name to log in with on the remote system. Requires that the remote system support the TELNET ENVIRON option. - /t -- Specifies terminal type. Supported term types are vt100, vt52, ansi and vtnt only. - /? -- Displays help at the command prompt. Remarks: Used without parameters, telnet starts Telnet Client. When at the telnet prompt, telnet commands must be used. The Telnet Client commands are: To stop Telnet Client, use either of these in the Telnet Client: - q or quit Stop/end/exit Telnet Client - o or open [\\RemoteServer] [Port] Connect to a remote computer - c or close [\\RemoteServer] Disconnect from a remote computer - d or display Display operating parameters - set Set options Type 'set ?' to see options list - sen or send Send strings to the server Type 'sen ?' to see options list - st or status Print status information - u or unset Unset options type 'unset ?' to see options list same as for SET except for logfile, mode and term - ? or help Print help information If a server is not specified, the local server is assumed. If a port is not specified, the default port is assumed. The options for the Telnet Client command 'SET' and 'UNSET' (except for logfile, mode and term) are: - bsasdel -- Sets BACKSPACE to be sent as delete. - crlf -- Sets the new line mode, which causes the ENTER key to send 0x0D, 0x0A. - delasbs -- Sets DELETE to be sent as backspace. - localecho -- Turns on local echo. - logging -- Turns on logging. If no log file is set, an error message appears. - ntlm -- Turns on NTLM authentication if it is available on the remote server. - escape Character -- Sets the escape character. The escape character can be a single character, or it can be a combination of the CTRL key plus a character. To set a control-key combination, hold down CTRL while typing the character to be assigned. To unassign or unset the escape character, use 'unset escape' without specifying a character. - logfile FileName -- Sets the file to be used for logging telnet activity. The log file must be on the local computer. Logging begins automatically when setting this option. - mode {console | stream} -- Sets the mode of operation. - term {ansi | vt100 | vt52 | vtnt} -- Sets the terminal to the specified type. - ? -- Allows viewing the complete syntax for this command. The options for the Telnet Client command 'SEN' are: - ao -- Aborts output command. - ayt -- Sends an "Are you there?" command. - esc -- Sends the current escape character. - ip -- Interrupts the process command. - synch -- Performs the telnet sync operation. - ? -- Allows viewing of the complete syntax for this command. Examples of the Telnet Client options: To set Telnet Client options, use this in the Telnet Client: set [\\RemoteServer] [ntlm] [localecho] [term {ansi | vt100 | vt52 | vtnt}] [escape Character] [logfile FileName] [logging] [bsasdel] [crlf] [delasbs] [mode {console | stream}] [?] If a server is not specified, the local server is assumed. To turn off an option that was previously set, at the telnet prompt, type: unset [Option] To set the escape character, type: e Character Note that on non-English versions of telnet, the codeset Option is available. Codeset Option sets the current code set to an option, which can be any one of the following: Shift JIS, Japanese EUC, JIS Kanji, JIS Kanji (78), DEC Kanji, NEC Kanji. The local PC needs to use the same code set on the remote computer. To send Telnet Client commands send [\\RemoteServer] [ao] [ayt] [esc] [ip] [synch] [?] If a server is not specified, the local server is assumed. To view the current settings for the Telnet Client display The display command lists the currently operating parameters for the Telnet Client. If in a telnet session (i.e., if connected to a telnet server), exit the telnet session to modify the parameters by pressing CTRL+]. To return to the telnet session, press ENTER. Examples of the Telnet Server options: FOR MORE INFORMATION, see http://technet.microsoft.com/en-us/library/cc772789%28WS.10%29.aspx tlntadmn [\\RemoteServer] [start] [stop] [pause] [continue] [-s] [-k{SessionID | all}] [-m {SessionID | all} "Message"] A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. - \\RemoteServer -- Specifies the name of the server that is to be managed. - start -- Starts Telnet Server. - stop -- Stops Telnet Server. - pause -- Interrupts Telnet Server. - continue -- Resumes Telnet Server. - /s -- Displays active telnet sessions. - /k{SessionID | all} -- Terminates sessions. Type the session ID to terminate a specific session, or type all to terminate all sessions. - /m {SessionID | all} "Message" -- Sends a message to one or more sessions. Type the session ID to send a message to a specific session, or type all to send a message to all sessions. Type the message to send between quotation marks (i.e. "Message"). - /? -- Displays help at the command prompt. If a server is not specified, the local server is assumed. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands can be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. To set logging options on a computer running Telnet Server tlntadmn [\\RemoteServer] config [auditlocation={eventlog | file | both}] [audit=[{+ | -}admin][{+ | -}user][{+ | -}fail]] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. auditlocation={eventlog | file | both} -- Specifies whether to send event information to Event Viewer, to a file, or to both. audit=[{+ | -}admin][{+ | -}user][{+ | -}fail] -- Specifies which events to audit (administrative logon events, user logon events, or failed logon attempts). To audit events of a particular type, type a plus sign (+) before that event type. To stop auditing events of a particular type, type a minus sign (-) before that event type. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. If where to send event information is specified without specifying which type or types of information to audit, only information about administrative logon events will be audited and sent to the location specified. Examples: To send event information to Event Viewer, type: tlntadmn config auditlocation=eventlog To audit administrative logon events and failed logon attempts, type: tlntadmn config audit=+admin +fail To set the default domain on a computer running Telnet Server tlntadmn [\\RemoteServer] config [dom=DomainName] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. dom=DomainName -- Specifies the domain to make the default domain. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. Examples: To make Redmond the default domain on the local server, type: tlntadmn config dom=Redmond To map the Alt key on a computer running Telnet Server tlntadmn [\\RemoteServer] config [ctrlakeymap={yes | no}] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. ctrlakeymap={yes | no} -- Specifies whether the Telnet Server should interpret CTRL+A as ALT. Type yes to map the shortcut key, or type no to prevent mapping. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. If the ALT key is not mapped, Telnet Server does not send the ALT key to applications that might rely on that key. To set the maximum number of connections on a computer running Telnet Server tlntadmn [\\RemoteServer] config [maxconn=PositiveInteger] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. maxconn=PositiveInteger -- Sets the maximum number of connections. This number must be specified with a positive integer that is smaller than 10 million. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. To set the maximum number of failed logon attempts on a computer running Telnet Server tlntadmn [\\RemoteServer] config [maxfail=PositiveInteger] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. maxfail=PositiveInteger -- Sets the maximum number of failed logon attempts that a user is allowed. This number must be specified with a positive integer that is smaller than 100. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. To set the mode of operation on a computer running Telnet Server tlntadmn [\\RemoteServer] config [mode={console | stream}] Parameters: \\RemoteServer -- Specifies the name for the server to manage. If a server is not specified, the local server is assumed. mode={console | stream} -- Specifies the mode of operation. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. To set the telnet port on a computer running Telnet Server tlntadmn [\\RemoteServer] config [port=IntegerValue] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. port=IntegerValue -- Sets the telnet port. The port must be specified with an integer smaller than 1,024. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. To set the methods of authentication on a computer running Telnet Server tlntadmn [\\RemoteServer] config [sec=[{+ | -}ntlm][{+ | -}passwd]] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. sec=[{+ | -}ntlm][{+ | -}passwd] -- Specifies whether to use NTLM, a password, or both to authenticate logon attempts. To use a particular type of authentication, type a plus sign (+) before that type of authentication. To prevent using a particular type of authentication, type a minus sign (-) before that type of authentication. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. NTLM is the authentication protocol for transactions between two computers where one or both computers is running Windows NT 4.0 or an earlier version. In addition, NTLM is the authentication protocol for computers that are not participating in a domain, such as stand-alone servers and workgroups. To set the time-out for idle sessions on a computer running Telnet Server tlntadmn [\\RemoteServer] config [timeout=hh:mm:ss] Parameters: \\RemoteServer -- Specifies the name of the server to manage. If a server is not specified, the local server is assumed. timeout=hh:mm:ss -- Sets the time-out period in hours, minutes, and seconds. /? -- Displays help at the command prompt. Remarks: A computer running Telnet Server can be remotely administered using the tlntadmn commands if both computers are running Windows XP. The tlntadmn commands cannot be used to remotely administer a computer running Windows 2000 and Telnet Server from a computer that is running Windows XP. Remarks: To switch from Telnet Client to command mode, at the telnet prompt, press CTRL+ ]. To switch back to Telnet Client, press ENTER.
TIME Displays or sets the system time. Used without parameters, time displays the system time and prompts you to enter a new time. time [/t] [/time] [hours:[minutes[:seconds[.hundredths]]][{A|P}]] Parameters: - /t -- Displays the current system time, without prompting to enter a new time. - / time -- Same as /t. - hours -- Specifies the hour. Valid values are in the range 0 through 23. - minutes -- Specifies minutes. Valid values are in the range 0 through 59. - seconds -- Specifies seconds. Valid values are in the range 0 through 59. - hundredths -- Specifies hundredths of a second. Valid values are in the range 0 through 99. - {A|P} -- Specifies A.M or P.M. for the 12-hour time format. If a valid 12-hour time is typed but do not type A or P, time uses A for A.M. - /? -- Displays help at the command prompt. Remarks: When using time without parameters, press ENTER to keep the same time. Using the /t parameter: ======================= The /t command-line option is only available if command extensions are enabled (i.e., the default). For more information about enabling and disabling command extensions, see cmd in Related Topics. Specifying an invalid time format: ================================== If the time is specified in an invalid format the following message is displayed and the system then waits for entry of the time in the correct format: Invalid time Enter new time:_ Changing the time format: ========================= The time format can be changed by changing the setting in Date and Time in Control Panel. For just the MS-DOS subsystem, change the country setting in thr Config.nt file. Depending on the Country/Region selected, time is displayed in the 12-hour format or the 24-hour format. If setting the time in the 12-hour format, specify P for hours after noon. Examples: To set the computer clock to 1:36 P.M., type either of the following commands: time 13:36 time 1:36P
System Clock Time/Date Settings
This is a short cut to start up the SYSTEM CLOCK TIME/DATE Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
TIMEDATE.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
TITLE Sets the window title for the command prompt window. title [string] Parameters: string -- Specifies the title for the command prompt window. /? -- Displays help at the command prompt. Remarks: To use the window title for batch programs, include the title command at the beginning of a batch program. Once set, the window title can be reset with the title command only. Examples: To set the window title for a batch program, type: rem This batch program updates the employee data: cls @echo off title Updating Files copy \\server\share\*.xls c:\users\common\*.xls echo Files Updated.
TREE Graphically displays the folder structure of a drive or path. tree [Drive:][Path] [/f] [/a] Parameters: Drive: -- Specifies the drive that contains the disk to display the directory structure. Path -- Specifies the directory to display the directory structure. /f -- Displays the names of the files in each directory. /a -- Specifies that tree is to use text characters instead of graphic characters to show the lines linking subdirectories. /? -- Displays help at the command prompt. Remarks: The structure displayed by tree depends upon the parameters specified on the command line. If a drive or path is not specified, tree displays the tree structure beginning with the current directory of the current drive. Examples: To display the names of all the subdirectories on the disk in the current drive, type: tree \ To display, one screen at a time, the files in all the directories on drive C, type: tree c:\ /f | more To print the same list that the previous example displayed, type: tree c:\ /f prn
TSCON Attaches a user session to a terminal session. Permission must be granted. tscon {SessionID | SessionName} [/dest:SessionName] [/password:pw] [/v] Parameters: - SessionID -- The ID of the session to which to connect. If the optional /dest:SessionName parameter is used, this is the ID of the session to which to connect. - SessionName -- The name of the session to connect. - /dest:SessionName -- Specifies the name of the current session. This session will disconnect when connecting to a new session. - /password:Password -- The password of the user who owns the session to which to connect. This password is required when the connecting user does not own the session. - /v -- Displays information about the actions being performed. - /? -- Displays help at the command prompt. Remarks: Full Control access permission must be available or Connect special access permission to connect to another session. The /dest:SessionName parameter allows connecting the session of another user to a different session. If a password is not specified in the Password parameter, and the target session belongs to a user other than the current one, tscon fails. Connect to the console session is not possible. Examples: To connect to session 12 on the current terminal server and disconnect the current session, type: tscon 12 To connect to session 23 on the current terminal server, using the password mypass, and disconnect the current session, type: tscon 23 /password:mypass To connect the session named TERM03 to the session named TERM05, and then disconnect session TERM05, if it is connected, type: tscon TERM03 /v /dest:TERM05
TSDISCON Disconnects a session from a terminal server. tsdiscon [{SessionID | SessionName}] [/server:ServerName] [/v] Parameters: - SessionID -- The ID of the session to disconnect. - SessionName -- The name of the session to disconnect. - /server:ServerName -- Specifies the terminal server containing the session to disconnect. Otherwise, the current terminal server is used. - /v -- Displays information about the actions being performed. - /? -- Displays help at the command prompt. Remarks: Full Control permission must be available to disconnect another user from a session. If no session ID or session name is specified, tsdiscon disconnects the current session. Any applications that were running when disconnect the session are automatically running when reconnect to that session with no loss of data. Use Reset session to end the running applications of the disconnected session, but be aware that this might result in loss of data at the session. The /server parameter is required only if tsdiscon is being used from a remote server. The console session cannot be disconnected. Examples: To disconnect the current session, type: tsdiscon To disconnect session 10, type: tsdiscon 10 To disconnect the session named TERM04, type: tsdiscon TERM04
TSKILL Ends a process. tskill {ProcessID | ProcessName} [/server:ServerName] [{/id:SessionID | /a}] [/v] Parameters:Parameters - ProcessID -- The ID of the process to end. - ProcessName -- The name of the process to end. Wildcards can be used to specify this parameter. - /server:ServerName -- Specifies the terminal server containing the process to end. Otherwise, the current terminal server is used. - /id:SessionID -- Ends the process running in the specified session. - /a -- Ends the process running in all sessions. - /v -- Displays information about the actions being performed. - /? -- Displays help at the command prompt. Remarks: tskill can be used to end only those processes belonging to the PC. Administrator can always used tskill since they have full access to all tskill functions and can end processes running in other user sessions. When all processes running in a session end, the session also ends.
TYPE Displays the contents of a text file or files. TYPE [drive:][path]filename Parameters: - [Drive:][Path] FileName -- Specifies the location and name of the file or files to view. Separate multiple file names with spaces. - /? -- Displays help at the command prompt. Remarks: If using an NTFS drive and FileName contains spaces, use quotation marks around the text (i.e., "File Name"). If displaying a binary file or a file created by a program, strange characters may be seen on the screen, including formfeed characters and escape-sequence symbols. These characters represent control codes used in the binary file. In general, avoid using the type command to display binary files. Examples: To display the contents of a file named Holiday.mar, type: type holiday.mar To display the contents of a lengthy file one screen at a time, type: type holiday.mar | more
Users Account Management
This is a short cut to start up the Users Account dialog.
Either make a shortcut on the desktop with this or do START then RUN then type in
'control userpasswords2' and click OK. Of course, it can also be entered at the
C:\ prompt in a CMD window.
VER Displays the Windows XP version. ver Parameters: - /? -- Displays help at the command prompt.
VERIFY
Tells cmd.exe to verify that the disk files are written correctly
VERIFY [ON | OFF]
Type VERIFY without a parameter to display the current VERIFY setting.
NOTE that this command is not valid on Windows XP or higher
VOL Displays the disk volume label and serial number, if they exist. vol [Drive:] Parameters: - Drive: : Specifies the drive that contains the disk for which you want to display the volume label and serial number. - /? -- Displays help at the command prompt.
WordPad Editor
This is a short cut to start up the WordPad editor. Optionally, the name of the
file to edit can be given. Otherwise, a new empty file is started.
This simple word processor is useful for viewing and modifying files whose contents
is made up only of basic formatting. The formatting includes:
- bold, italics, underline
- font family and size and color
- bulleted lists
- Images
No tables or numbered lists or spell checker or thesaurus are available.
Either make a shortcut on the desktop with this or do START then RUN then type in
WRITE and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
Security Center Settings
This is a short cut to start up the Security Center Settings portion of the Control Panel.
Either make a shortcut on the desktop with this or do START then RUN then type in
WSCUI.CPL and click OK. Of course, it can also be entered at the C:\ prompt in a
CMD window.
XCOPY Copies files and directories, including subdirectories. xcopy Source [Destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d[:mm-dd-yyyy]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a|/m}] [/n] [/o] [/x] [/exclude:file1[+[file2]][+[file3]] [{/y|/-y}] [/z] Parameters: Source -- Required. Specifies the location and names of the files to copy. This parameter must include either a drive or a path. Destination -- Specifies the destination of the files to copy. This parameter can include a drive letter and colon, a directory name, a file name, or a combination of these. - /p -- Prompts to confirm whether to create each destination file. - /c -- Ignores errors. - /v -- Verifies each file as it is written to the destination file to make sure that the destination files are identical to the source files. - /q -- Suppresses the display of xcopy messages. - /f -- Displays source and destination file names while copying. - /l -- Displays a list of files that are to be copied. - /g -- Creates decrypted destination files. - /d[:mm-dd-yyyy] -- Copies source files changed on or after the specified date only. If a mm-dd-yyyy value is not included, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows updating only the files that have changed. - /u -- Copies files from Source that exist on Destination only. - /i -- If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts to specify whether Destination is a file or a directory. - /s -- Copies directories and subdirectories, unless they are empty. If /s is omitted, xcopy works within a single directory. - /e -- Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line options. - /t -- Copies the subdirectory structure (i.e. the tree) only, not files. To copy empty directories, include the /e command-line option. - /k -- Copies files and retains the read-only attribute on destination files if present on the source files. By default, xcopy removes the read-only attribute. - /r -- Copies read-only files. - /h -- Copies files with hidden and system file attributes. By default, xcopy does not copy hidden or system files. - /a -- Copies only source files that have their archive file attributes set. /a does not modify the archive file attribute of the source file. For information about how to set the archive file attribute by using attrib, see Related Topics. - /m -- Copies source files that have their archive file attributes set. Unlike /a, /m turns off archive file attributes in the files that are specified in the source. For information about how to set the archive file attribute by using attrib, see Related Topics. - /n -- Creates copies by using the NTFS short file or directory names. /n is required to copy files or directories from an NTFS volume to a FAT volume or when the FAT file system naming convention (i.e. 8.3 characters) is required on the destination file system. The destination file system can be FAT or NTFS. - /o -- Copies file ownership and discretionary access control list (DACL) information. - /x -- Copies file audit settings and system access control list (SACL) information (implies /o). - /exclude:filename1[+[filename2]][+[filename3]] -- Specifies a list of files containing strings. - /y -- Suppresses prompting to confirm to overwrite an existing destination file. - /-y -- Prompts to confirm to overwrite an existing destination file. - /z -- Copies over a network in restartable mode. - /w -- Displays the following message and waits for a response before s starting to copy files: Press any key to begin copying file(s) - /? -- Displays help at the command prompt. Remarks: Using /v ========= Windows XP does not use this command. It is accepted only for compatibility with MS-DOS files. Using /exclude: =============== List each string in a separate line in each file. If any of the listed strings match any part of the absolute path of the file to be copied, that file is then excluded from the copying process. For example, if the string "\Obj\" is specified, exclude all files underneath the Obj directory. If specify the string ".obj", exclude all files with the .obj extension. Using /z: ========= If the connection is lost during the copy phase (for example, if the server going offline severs the connection), it resumes after reestablishing the connection. /z also displays the percentage of the copy operation completed for each file. Using /y in the COPYCMD environment variable: ============================================= Use /y in the COPYCMD environment variable. Override this command by using /-y on the command line. The default to overwrite is prompted, unless xcopy is run from within a batch script. Copying encrypted files: ======================== Copying encrypted files to a volume that does not support EFS results in an error. Decrypt the files first or copy the files to a volume that does support EFS. Appending files: ================ To append files, specify a single file for destination, but multiple files for source (i.e. by using wildcards or file1+file2+file3 format). Default value for Destination: ============================== If Destination is omitted, the xcopy command copies the files to the current directory. Specifying whether Destination is a file or directory: ====================================================== If Destination does not contain an existing directory and does not end with a backslash (\), the following message appears: Does destination specify a file name or directory name on the target (F = file, D = directory)? Press F to copy the file or files to a file. Press D to copy the file or files to to a directory. This message can be suppressed by using the /i command-line option, which causes xcopy to assume that the destination is a directory if the source is more than one file or a directory. Using the xcopy command to set archive attribute for Destination files The xcopy command creates files with the archive attribute set, whether or not this attribute was set in the source file. For more information about file attributes and attrib, see Related Topics. Comparing xcopy and diskcopy: ============================= If a disk that contains files in subdirectories and want to copy it to a disk that has a different format, use the xcopy command instead of diskcopy. Because the diskcopy command copies disks track by track, the source and destination disks must have the same format. The xcopy command does not have this requirement. Use xcopy unless a complete disk image copy is needed. Exit codes for xcopy: ===================== To process exit codes returned by xcopy, use the errorlevel parameter on the if command line in a batch program. For an example of a batch program that processes exit codes using if, see Related Topics. The following table lists each exit code and a description. Exit code - Description 0 - Files were copied without error. 1 - No files were found to copy. 2 - The user pressed CTRL+C to terminate xcopy. 4 - Initialization error occurred. There is not enough memory or disk space, or an invalid drive name was entered or invalid syntax was specified on the command line. 5 - Disk write error occurred. Examples: To copy all the files and subdirectories (including any empty subdirectories) from drive A to drive B, type: xcopy a: b: /s /e To include any system or hidden files in the previous example, add the/h command-line option as follows: xcopy a: b: /s /e /h To update files in the \Reports directory with the files in the \Rawdata directory that have changed since December 29, 1993, type: xcopy \rawdata \reports /d:12-29-1993 To update all the files that exist in \Reports in the previous example, regardless of date, type: xcopy \rawdata \reports /u To obtain a list of the files to be copied by the previous command (i.e. without actually copying the files), type: xcopy \rawdata \reports /d:12-29-1993 /l > xcopy.out The file Xcopy.out lists every file that is to be copied. To copy the \Customer directory and all subdirectories to the directory \\Public\Address on network drive H:, retain the read-only attribute, and be prompted when a new file is created on H:, type: xcopy \customer h:\public\address /s /e /k /p To issue the previous command, ensure that xcopy creates the \Address directory if it does not exist, and suppress the message that appears when creating a new directory, add the /i command-line option as follows: xcopy \customer h:\public\address /s /e /k /p /i To create a batch program to perform xcopy operations and use the batch if command to process the exit code if an error occurs. For example, the following batch program uses replaceable parameters for the xcopy source and destination parameters: @echo off rem COPYIT.BAT transfers all files in all subdirectories of rem the source drive or directory (%1) to the destination rem drive or directory (%2) xcopy %1 %2 /s /e if errorlevel 4 goto lowmemory if errorlevel 2 goto abort if errorlevel 0 goto exit :lowmemory echo Insufficient memory to copy files or echo invalid drive or command-line syntax. goto exit :abort echo You pressed CTRL+C to end the copy operation. goto exit :exit To copy all source files, including subdirectories and even empty subdirections, plus retain the read-only attribute of source files that have them, to the destination folder (which is created if not existing) and do so without any prompting for overwriting or displaying what is being copied, type: set COPYCMD=/Y XCOPY C:\source_dir\*.* %1:\destination_dir /Q /D /E /R /K /Y /I set COPYCMD=-Y Note that the two "set COPYCMD's are there to assure that no prompting is done for file overwrites. Just a bit of extra insurance for some operating systems such as Win2000. To use this batch program to copy all files in the C:\Prgmcode directory and its subdirectories to drive B, type: copyit c:\prgmcode b: The command interpreter substitutes C:\Prgmcode for %1 and B: for %2, then uses xcopy with the /e and /s command-line options. If xcopy encounters an error, the batch program reads the exit code and goes to the label indicated in the appropriate IF ERRORLEVEL statement, then displays the appropriate message and exits from the batch program.
VARIOUS CODING EXAMPLES
GET/SET DRIVE LETTER AS PARAMETER Get the Drive letter parameter and if not present then default it to "C": Demonstrate: IF....GOTO Demonstrate: SET if "%1" == "" goto SetDrive SET DRIVE=%1 goto ContinueThis :SetDrive SET DRIVE=C :ContinueThis
VALIDATE PARAMETERS GIVEN Check for required parameter(s) and if missing then show expected command line syntax Demonstrate: IF....GOTO Demonstrate: IF....GOTO NOT EXIST Demonstrate: SET ERRORLEVEL @ECHO OFF if "%1" == "" goto showSyntax if "%1" == "" goto showSyntax rem assume parameter #1 is a directory name and if it does not exist, create it and check if that failed if not exist "%1" md "%1" if not exist "%1" goto badDirectory rem do whatever here....... goto exitTime :showSyntax echo Usage: thisBatchFileName directoryNameToUse echo. echo where directoryNameToUse is the name of the folder where the action happens set ERRORLEVEL=2 goto exitTime :badDirectory echo the directory given as the parameter could not be created set ERRORLEVEL=1 goto exittime :exitTime
EMPTY RECYCLE BIN Clear the Recycle Bin rd /s %systemdrive%\$Recycle.bin
GET DATE/TIME VARIABLES Get the current date/time into separate variables Demonstrate: IF Demonstrate: SET @ECHO OFF set hh=%time:~0,2% if "%hh:~0,1%" == " " set hh=0%hh:~1,1% set mn=%time:~3,2% if "%mn:~0,1%" == " " set mn=0%mn:~1,1% set ss=%time:~6,2% if "%ss:~0,1%" == " " set ss=0%ss:~1,1% set yy=%date:~-4% set mm=%date:~4,2% if "%mm:~0,1%" == " " set mm=0%mm:~1,1% set dd=%date:~7,2% if "%dd:~0,1%" == " " set dd=0%dd:~1,1% echo it currently is %mm%/%dd%/%yy% %hh%:%mn%:%ss%
GET DAY OF WEEK VARIABLE Get the day of the week (WIN7 or WIN8) Demonstrate: WMIC Demonstrate: FOR Demonstrate: IF/ELSE @echo off rem get 24-hour time for /F "tokens=1-4 delims=: " %%i in ('time /t') do ( set Hr=%%i set Mn=%%j set AP=%%k ) if "%AP%"=="PM" (set /a H=%Hr%+12) ELSE (set /a H = %Hr%+0) rem get date including day of week as an abbreviation wmic path win32_localtime get dayofweek for /F "tokens=1-4 delims=/ " %%i in ('date /t') do ( set WD=%%i set D=%%j set M=%%k set Y=%%l ) echo currently it is %Y%/%M%/%D% %H%:%Mn% on a %WD%
SYNC FOLDERS CONTENT Sync the files in two folders/directories Demonstrate: IF.....GOTO Demonstrate: COPYCMD @ECHO OFF if "%1" == "" goto NeedBothFolders if "%2" == "" goto NeedBothFolders set COPYCMD=/Y xcopy %1\*.* %2 /Q /D /E /R /K /Y set COPYCMT=-Y goto exittime :NeedBothFolders echo Valid usage syntax is: echo nameofthisbatfile.bat X Y echo where X is the full path of the FROM folder (without an ending backslash) echo and Y is the full path of the TO folder :exittime echo DONE...
ASSIGN DRIVE TO REMOTE PC On a network, link a server/PC to a temporarily assigned drive NOTE: it starts at Z looking for the first open drive Then the temporary drive gets unassigned via the "popd" Demonstrate: PUSHD and POPD pushd %tempdrv% rem do whatever for the new drive, refer to it with a period rem e.g. copy c:\myfiles\*.* .\backup\ /Q popd
REBOOT LOCALLY OR REMOTELY Reboot the PC, even remotely, after a given delay (in # of seconds) Demonstrate: TIMEOUT Demonstrate: SHUTDOWN @ECHO OFF rem pause for 60 seconds timeout /T 60 echo . . . . . rebooting in 6 seconds ..... timeout /T 5 shutdown -r -f -t 1 -m \\computernamehereCouldUseSystemVariableCalled%ComputerName%
EXPORT A REGISTRY KEY Retrieve from the System Registry the value(s) for the given Registry key Demonstrate: FOR Demonstrate: DO @ECHO OFF rem basically, say "REG" followed by registry key to export followed by name of file to export the key values into REG EXPORT HKEY_CLASSES_ROOT\Excel.Sheet.12 "c:\mypath\myfolder\excel12.reg"
IMPORT A REGISTRY KEY Add System Registry entries from a prior export Demonstrate: REGEDIT regedit.exe /S my_first_exported_registry_key.reg pause regedit.exe /S my_second_exported_registry_key.reg
SHOW INSTALLED PROGRAMS LIST IN EXCEL Get a listing of all installed software and their versions, open CSV in Excel Demonstrate: WMIC Demonstrate: MORE Demonstrate: START @echo off rem clean up final output file del C:\Software_%Computername%.csv /Q rem create a temp file with the column hdgs rem NOTE, despite order of columns selected, WMIC puts columns in its own order echo Node,InstallDate,InstallLocation,Name,ProductCode,Vendor,Version>> c:\csv_col_hdgs.txt rem generate the output file (sans column headings) echo this might take a couple of minutes to generate wmic /output:c:\garbagefirstline.txt product get Name,Version,Vendor,InstallDate,PackageCode,InstallLocation /format:csv rem the WMIC outputs a junk line instead of column headings so use the MORE command to start at line #2 more +2 "garbagefirstline.txt" > "csv_output_no_col_hdgs.txt" rem combine the two files generated above into one CSV file and open it with Excel type c:\csv_col_hdgs.txt >> C:\Software_%Computername%.csv" type c:\csv_output_no_col_hdgs.txt >> C:\Software_%Computername%.csv" start excel C:\Software_%Computername%.csv rem NOW, if you want to get really fancy, add VBA to rearrange the column order, freeze the top row, rem and set column widths
SEARCH THE LINES IN A TEXT FILE FOR A SPECIFIC VALUE Demonstrate: FINDSTR Use "FINDSTR" to filter out lines in a text file (.txt,.csv,.ini,etc.) In this example, the input file is searched for a specific value and once the record is found then another value within the record is actually wanted. The values in each record are delimited by some character. rem The values within each record of the input file are delimited by the below character (semi-colon in this case) rem The record key being searched is the first value in each record and is a numeric value in this example. rem The record value wanted from the search, in the example, is the third value within each record. set delimchar=; set valueToFind=18%delimchar% set myrecordkey= for /f "delims=" %%s in ('FINDSTR /B /I /C:%valueToFind% c:\mydatapath\myinputfile.csv ') do ( set "myfoundrec=%%s" ) echo Found=%myfoundrec% set outvalue= rem parse found record value to extract the value wanted for /f "tokens=1,2,3,4 delims=%delimchar%" %%a in ("%myfoundrec%") do set outvalue=%%c echo %outvalue%
READ THE LINES IN A TEXT FILE Demonstrate: FOR Read the lines in a text file (.txt,.csv,.ini,etc.) In this example, a comma-delimited file is read in, twice. The first time the file records are shown as one long string. The second time the individual fields within each file record are shown with double colons between them. Instead of doing "@echo" any of the various %%X fields could be used to set the value into a variable. Within a single FOR statement, the most %%X variables is 31. That is the 26 uppercase letters plus the five special characters used below. Note that, by default, the /F considers a blank space to be the beginning of a new record or line. for /F "first showing done, each record as one long string FOR /F "tokens=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 delims=," %%? in (c:\testfile.csv) do @echo %%? :: %%@ :: %%A :: %%B :: %%C :: %%D :: %%E :: %%F :: %%G :: %%H :: %%I :: %%J :: %%K :: %%L :: %%M :: %%N :: %%O :: %%P :: %%Q :: %%R :: %%S :: %%T :: %%U :: %%V :: %%W :: %%X :: %%Y :: %%Z :: %%[ :: %%\ :: %%] :: pause ...second showing done CONDITIONALLY FILTER/REMOVE LINES FROM A TEXT FILE Demonstrate: FINDSTR Use "FINDSTR" to filter out lines in a text file (.txt,.csv,.ini,etc.) In this example, if any line of the input file contains any of the three given words then it will NOT be included in the output file FINDSTR /v "CASE_SENSITIVE_WORD_1 CASE_SENSITIVE_WORD_2 AND_MORE" c:\inputfile.txt > c:\outputfile.txt
RENAME GROUP OF FILE EXTENSIONS Rename all files with the extension of HTM (uppercase) to html (lowercase) Demonstrate: FOR for /f "Tokens=*" %%f in ('dir /l/b/a-d *.htm') do (rename "%%f" "%%f"l)
CALL BATCH FROM BATCH Execute a batch file from a batch file with optional parameters Demonstrate: CALL call batchfilename2.bat param1 param2 param3
EXECUTE EXTERNAL PROGRAM (see START) Execute an executable program (extension EXE) from a batch program Demonstrate: START start programname.exe programname.exe
COMPILE/RUN JAVA Compile then run a java program from a batch file Demonstrate: JAVA and JAVAC javac -deprecation -classpath . nameOfJavaFileHere.java javac -deprecation -classpath .;c:\folder1\folder2 -d c:\folder1\folder2\%1 nameOfJavaFileHere.java java nameOfJavaFileHere
TEMPORARILY ALTER SYSTEM PATH Temporarily add directories to the System Path Demonstrate: PATH ALTERING PATH=c:\myfolder;%PATH%
GET SYSTEM INFORMATION Gather/display various types of System Information Demonstrate: SYSTEMINFO, FINDSTR, WMIC @echo off echo Checking system information........... echo (ignore the message about loading HotFix Information) systeminfo | findstr /c:"Computer Name" systeminfo | findstr /c:"Domain" systeminfo | findstr /c:"OS Name" systeminfo | findstr /c:"OS Version" systeminfo | findstr /c:"System Manufacturer" systeminfo | findstr /c:"System Model" systeminfo | findstr /c:"System type" systeminfo | findstr /c:"Total Physical Memory" ipconfig | findstr IPv4 echo Hard Drive Space: wmic logicaldisk get caption,size echo Service Tag: wmic bios get serialnumber echo CPU: wmic cpu get name pause Done!
FYI - use these for numeric comparison in Batch: EQU - equal NEQ - not equal LSS - less than LEQ - less than or equal GTR - greater than GEQ - greater than or equal