Arp
Displays and modifies entries in the Address Resolution Protocol (ARP) cache, which contains one or more tables that are used to store IP addresses and their resolved Ethernet or Token Ring physical addresses. There is a separate table for each Ethernet or Token Ring network adapter installed on your computer. Used without parameters, arp displays help.
Syntax
arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]] [-d InetAddr [IfaceAddr]] [-s InetAddr EtherAddr [IfaceAddr]]
Top of page
Parameters
-a [ InetAddr ] [ -N IfaceAddr ] : Displays current ARP cache tables for all interfaces. To display the ARP cache entry for a specific IP address, use arp -a with the InetAddr parameter, where InetAddr is an IP address. To display the ARP cache table for a specific interface, use the -N IfaceAddr parameter where IfaceAddr is the IP address assigned to the interface. The -N parameter is case-sensitive.
-g [ InetAddr ] [ -N IfaceAddr ] : Identical to -a.
-d InetAddr [ IfaceAddr ] : Deletes an entry with a specific IP address, where InetAddr is the IP address. To delete an entry in a table for a specific interface, use the IfaceAddr parameter where IfaceAddr is the IP address assigned to the interface. To delete all entries, use the asterisk (*) wildcard character in place of InetAddr.
-s InetAddr EtherAddr [ IfaceAddr ] : Adds a static entry to the ARP cache that resolves the IP address InetAddr to the physical address EtherAddr. To add a static ARP cache entry to the table for a specific interface, use the IfaceAddr parameter where IfaceAddr is an IP address assigned to the interface.
/? : Displays help at the command prompt.
Remarks
The IP addresses for InetAddr and IfaceAddr are expressed in dotted decimal notation.
The physical address for EtherAddr consists of six bytes expressed in hexadecimal notation and separated by hyphens (for example, 00-AA-00-4F-2A-9C).
Entries added with the -s parameter are static and do not time out of the ARP cache. The entries are removed if the TCP/IP protocol is stopped and started. To create permanent static ARP cache entries, place the appropriate arp commands in a batch file and use Scheduled Tasks to run the batch file at startup.
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 ARP cache tables for all interfaces, type:
arp -a
To display the ARP cache table for the interface that is assigned the IP address 10.0.0.99, type:
arp -a -N 10.0.0.99
To add a static ARP cache entry that resolves the IP address 10.0.0.80 to the physical address 00-AA-00-4F-2A-9C, type:
arp -s 10.0.0.80 00-AA-00-4F-2A-9C
Formatting legend
Format
Meaning
Italic
Information that the user must supply
Bold
Elements that the user must type exactly as shown
Ellipsis (...)
Parameter that can be repeated several times in a command line
Between brackets ([])
Optional items
Between braces ({}); choices separated by pipe (|). Example: {even|odd}
Set of choices from which the user must choose only one
Courier font
Code or program output
Assoc
Displays or modifies file name extension associations. Used without parameters, assoc displays a list of all the current file name extension associations.
Syntax
assoc [.ext[=[filetype]]]
Parameters
. ext : Specifies the file name extension.
filetype : Specifies the file type with which you want to associate the specified file name extension.
/? : Displays help at the command prompt.
Top of page
Remarks
Use a white space after the equal sign to delete the file type association for a file name extension.
Use the ftype command to view current file types that have open command strings defined.
Use the > redirection operator to redirect the output of assoc to a text file.
Examples
To view the current file type association for the file name extension .txt, type:
assoc .txt
To delete the file type association for the file name extension .txt, type:
assoc . txt =
To view current file type associations one screen at a time, type:
assoc | more
To send the output of assoc to the file Assoc.cfg, type:
assoc>assoc.cfg
Displays one screen of output at a time.
Syntax
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 for which you want to display the output.
/c : Clears screen before displaying page.
/p : Expands form-feed characters.
/s : Changes multiple blank lines to one blank line.
/t n : 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 (<), you must specify a file name as the source. When using the pipe (|), you can use such commands as dir, sort, and type.
Examples
To view the file named Clients.new that you want to view on your 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 --
You can then 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=<space><ret>] --
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 you 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 you 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.
Using command redirection operators
You can use redirection operators 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 table lists operators that you can use 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, you send the command input (that is, the STDIN handle) from your keyboard to Cmd.exe, and then Cmd.exe sends the command output (that is, 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 (that is, 0-9) represent the first 10 handles. You can use Cmd.exe to run a program and redirect any of the first 10 handles for the program. To specify which handle you want to use, type the number of the handle before the redirection operator. If you do not define a handle, the default < redirection input operator is zero (0) and the default > redirection output operator is one (1). After you type the < or > operator, you must specify where you want to read or write the data. You can specify a file name or another existing handle.
To specify redirection to existing handles, use the ampersand (&) character followed by the handle number that you want to redirect (that is, &handle#). For example, the following command redirects handle 2 (that is, STDERR) into handle 1 (that is, 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 you duplicate a handle, you 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. You 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:
sort<file.txt
The contents of File.txt appear in the Command Prompt window as an alphabetized list.
The < operator opens the specified file name with read-only access. As a result, you cannot write to the file when you use this operator. For example, if you start a program with <&2, all attempts to read handle 0 fail because handle 2 is initially opened with write-only access.
Note
Zero is the default handle for the < redirection input operator.
Redirecting command output (>)
Almost all commands send output to your 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. You can use this operator with most commands. For example, to redirect dir output to Dirlist.txt:
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, you cannot read the file when you use this operator. For example, if you 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 you specify 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 you specify a handle, Cmd.exe duplicates the handle you specify onto the existing handle in the system.
For example, to open File.txt as input read to handle 0 (that is, STDIN), type:
< file.txt
To open File.txt, sort the contents and then send the output to the Command Prompt window (that is, STDOUT), type:
sort< file.txt
To find File.txt, and then redirect handle 1 (that is, STDOUT) and handle 2 (that is, STDERR) to the Search.txt, type:
findfile file.txt>search.txt 2<&1
To duplicate a user-defined handle 3 as input read to handle 0 (that is, STDIN), type:
<&3
Using the >& operator to redirect output and duplicate
If you redirect output to a file and you specify an existing file name, Cmd.exe opens the file as write-only and overwrites the file's contents. If you specify a handle, 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 (that is, STDERR), from the ipconfig command to handle 1 (that is, 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 (that is, >>). 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 (that is, STDOUT).
Combining commands with redirection operators
You can create custom commands by combining filter commands with other commands and file names. For example, you can 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
By using a pipe (|), you 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
|