Win-cmd


go to main page

(0)How to find which routers or subnets might be having network problems?
(1)How can you localize changes?
(2)How to autocomplete file name and pathname?
(3)What is ARP?
(4)How to find network configuration like what modem is in use?
(5)How to compare two files?
(6)How to take user input?
(7)How to enable Security tabs for files and folder?
(8)How to remove all read only attribute in the current directory?
(9)How to remove all files and folders?
(10)How to searche for a specific string of text in a file or files
(11)How to show the active TCP connections and ports on which the computer is listening?
(12)How to find who is on a particular IP ?
(13)What is XCopy command?
(14)What is ATM?
(15)How to audit User Access of Files, Folders, and Printers?
(16)How to copy files with attributes?
(17)what the Archive attribute is used for?
(18)How to trace route for a internet connection?
(19)How to open Command-line reference?
(20)How to show current directory?
(21)How to create directory strucutre but no copying files?
(22)How to create folder and copy specified file at a time?
(23)How to find name and path of the batch file within the batch file?
(24)What is ACL?
(25)What is batch file?
How to find which routers or subnets might be having network problems?
pathping hostname

Pathping will first list the number of hops required to reach the address you are testing and then send multiple pings to each router between you and the destination. After that, it computes results based on the packets returned from each router. Because pathping displays the degree of packet loss at any given router or link, you can determine which routers or subnets might be having network problems. Note that the whole process may consume 5-10 minutes because many pings are being sent. There are switches to modify the process and these can be seen by entering "pathping /?" in the command prompt.
Example
E:\Hpro\Q-A\bin>pathping google.com

Tracing route to google.com [74.125.45.100]
over a maximum of 30 hops:
  0  home-bc2a5cd78c.globalsuite.net [172.17.176.166]
  1  172.17.1.1
  2  65.217.42.129
  3  500.Serial1-3-3-17-0.GW6.GSO1.ALTER.NET [65.208.82.133]
  4  0.ge-3-1-0.XL1.GSO1.ALTER.NET [152.63.41.94]
  5  0.so-6-0-0.XL3.IAD8.ALTER.NET [152.63.0.138]
  6  0.xe-9-0-0.BR1.IAD8.ALTER.NET [152.63.41.49]
  7  te-11-3-0.edge1.Washington4.level3.net [4.68.63.169]
  8  ae-1-69.edge1.Washington1.Level3.net [4.68.17.16]
  9  GOOGLE-INC.edge1.Washington1.Level3.net [4.79.22.38]
 10  209.85.240.136
 11  72.14.238.136
 12  72.14.232.213
 13  209.85.253.137
 14  yx-in-f100.google.com [74.125.45.100]

Computing statistics for 350 seconds...
            Source to Here   This Node/Link
Hop  RTT    Lost/Sent = Pct  Lost/Sent = Pct  Address
  0                                           home-bc2a5cd78c.globalsuite.net [172.17.176.166]
                                0/ 100 =  0%   |
  1   22ms     0/ 100 =  0%     0/ 100 =  0%  172.17.1.1
                                0/ 100 =  0%   |
  2   23ms     0/ 100 =  0%     0/ 100 =  0%  65.217.42.129
                                0/ 100 =  0%   |
  3   38ms     0/ 100 =  0%     0/ 100 =  0%  500.Serial1-3-3-17-0.GW6.GSO1.ALTER.NET [65.208.82.133]
                                0/ 100 =  0%   |
  4   36ms     0/ 100 =  0%     0/ 100 =  0%  0.ge-3-1-0.XL1.GSO1.ALTER.NET [152.63.41.94]
                                0/ 100 =  0%   |
  5   45ms     0/ 100 =  0%     0/ 100 =  0%  0.so-6-0-0.XL3.IAD8.ALTER.NET [152.63.0.138]
                                0/ 100 =  0%   |
  6   51ms     0/ 100 =  0%     0/ 100 =  0%  0.xe-9-0-0.BR1.IAD8.ALTER.NET [152.63.41.49]
                                0/ 100 =  0%   |
  7   56ms     0/ 100 =  0%     0/ 100 =  0%  te-11-3-0.edge1.Washington4.level3.net [4.68.63.169]
                                0/ 100 =  0%   |
  8   60ms     1/ 100 =  1%     1/ 100 =  1%  ae-1-69.edge1.Washington1.Level3.net [4.68.17.16]
                                0/ 100 =  0%   |
  9  ---     100/ 100 =100%   100/ 100 =100%  GOOGLE-INC.edge1.Washington1.Level3.net [4.79.22.38]
                                0/ 100 =  0%   |
 10   58ms     0/ 100 =  0%     0/ 100 =  0%  209.85.240.136
                                0/ 100 =  0%   |
 11   82ms     0/ 100 =  0%     0/ 100 =  0%  72.14.238.136
                                0/ 100 =  0%   |
 12   82ms     1/ 100 =  1%     1/ 100 =  1%  72.14.232.213
                                0/ 100 =  0%   |
 13   87ms     0/ 100 =  0%     0/ 100 =  0%  209.85.253.137
                                0/ 100 =  0%   |
 14   82ms     0/ 100 =  0%     0/ 100 =  0%  yx-in-f100.google.com [74.125.45.100]

Trace complete.

TOP
How can you localize changes?
by cmd and exit command (nesting command shells). we can further localize a subshell by setlocal and endlocal.
TOP
How to autocomplete file name and pathname?
Use TAB.
TOP
What is ARP?
Address Resolution Protocol (ARP) is a protocol for mapping an Internet Protocol address (IP address) to a physical machine address that is recognized in the local network. The physical machine address is also known as a Media Access Control or MAC address. A table, usually called the ARP cache, is used to maintain a correlation between each MAC address and its corresponding IP address.
cmd: arp
TOP
How to find network configuration like what modem is in use?
netsh diag show all
netsh diag gui
TOP
How to compare two files?
FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn] [drive1:][path1]filename1 [drive2:][path2]filename2
FC /B [drive1:][path1]filename1 [drive2:][path2]filename2
TOP
How to take user input?
set /p variable= [string]
Example
set /p name= What is your name?

TOP
How to enable Security tabs for files and folder?
Uncheck "Simple File Sharing" in Windows Explorer | Tools | Options
TOP
How to remove all read only attribute in the current directory?
attrib -r /s *

Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [drive:][path][filename] [/S [/D]]
TOP
How to remove all files and folders?
del can delelte all files with /s but doesn't delete folders. RD can be used for the purspose.
RD
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

    /S      Removes all directories and files in the specified directory
            in addition to the directory itself.  Used to remove a directory
            tree.

    /Q      Quiet mode, do not ask if ok to remove a directory tree with /S
DEL
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

  names         Specifies a list of one or more files or directories.
                Wildcards may be used to delete multiple files. If a
                directory is specified, all files within the directory
                will be deleted.

  /P            Prompts for confirmation before deleting each file.
  /F            Force deleting of read-only files.
  /S            Delete specified files from all subdirectories.
  /Q            Quiet mode, do not ask if ok to delete on global wildcard
  /A            Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                -  Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.

TOP
How to searche for a specific string of text in a file or files
FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]] If a path is not specified, FIND searches the text typed at the prompt or piped from another command.
TOP
How to show the active TCP connections and ports on which the computer is listening?
Netstat displays the active TCP connections and ports on which the computer is listening, Ethernet statistics, the IP routing table, statistics for the IP, ICMP, TCP, and UDP protocols. It comes with a number of switches for displaying a variety of properties of the network and TCP connections. (One tricky point: the switches must be prefixed with a minus, not a slash.) More detail is at this page. One possible use for Netstat is to determine if spyware or Trojans have established connections that you do not know about. The command "netstat -a" will display all your connections. The command "netstat -b" will show the executable files involved in creating a connection. A figure showing all the switches and syntax is given below.
TOP
How to find who is on a particular IP ?
Nslookup
Example
E:\Hpro\Q-A\bin>nslookup 4.2.2.1
Server:  vnsc-pri.sys.gtei.net
Address:  4.2.2.1

Name:    vnsc-pri.sys.gtei.net
Address:  4.2.2.1

TOP
What is XCopy command?
Copies files and directory trees.
XCOPY allows one to copy both files and directories in one command vs copying a folder or files in a folder one at a time using the COPY command. COPY does not allow you to copy subdirectories w/the *.*
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]...] The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line.
TOP
What is ATM?
Asynchronous Transfer Mode (ATM) is a technology that has the potential of revolutionizing data communications and telecommunications. Based on the emerging standards for Broadband Integrated Services Digital Networks (B-ISDN), ATM offers the economically sound "bandwidth on demand" features of packet-switching technology at the high speeds required for today's LAN and WAN networks -- and tomorrow's.
Command: atmadm [/c][/a] [/s]

Parameters


TOP
How to audit User Access of Files, Folders, and Printers?
The audit log appears in the Security log in Event Viewer. To enable this feature:
  1. Click Start, click Control Panel, click Performance and Maintenance, and then click Administrative Tools.
  2. Double-click Local Security Policy.
  3. In the left pane, double-click Local Policies to expand it.
  4. In the left pane, click Audit Policy to display the individual policy settings in the right pane.
  5. Double-click Audit object access.
  6. To audit successful access of specified files, folders and printers, select the Success check box.
  7. To audit unsuccessful access to these objects, select the Failure check box.
  8. To enable auditing of both, select both check boxes.
  9. Click OK.

 

Specifying Files, Folders, and Printers to Audit

After you enable auditing, you can specify the files, folders, and printers that you want audited. To do so:
  1. In Windows Explorer, locate the file or folder you want to audit. To audit a printer, locate it by clicking Start, and then clicking Printers and Faxes.
  2. Right-click the file, folder, or printer that you want to audit, and then click Properties.
  3. Click the Security tab, and then click Advanced.
  4. Click the Auditing tab, and then click Add.
  5. In the Enter the object name to select box, type the name of the user or group whose access you want to audit. You can browse the computer for names by clicking Advanced, and then clicking Find Now in the Select User or Group dialog box.
  6. Click OK.
  7. Select the Successful or Failed check boxes for the actions you want to audit, and then click OK.
  8. Click OK, and then click OK.

TOP
How to copy files with attributes?
XCopy /K Copies attributes. Normal Xcopy will reset read-only attributes.
TOP
what the Archive attribute is used for?
The archive attribute is set each time you create or change a file. It can be reset by direct action (attrib.exe), by xcopy.exe, by ntbackup.exe and probably by a few other programs.

It's used by backup programs to do incremental backups, it tells the backup software that the file was changed since the last backup, so the backup software will backup the file again then remove the attribute so that it doesn't copy the file again on its next backup. Other copying utilities, like xcopy, can also copy files based on the attribute when the right switches are used when launching the utilities. You can remove the attribute at the Command Prompt with the attrib command.
TOP
How to trace route for a internet connection?
tracert hostname
Example

E:\Hpro\Q-A\bin>tracert google.com

Tracing route to google.com [74.125.45.100]
over a maximum of 30 hops:

  1    23 ms    22 ms    22 ms  172.17.1.1
  2    23 ms    23 ms    22 ms  65.217.42.129
  3    96 ms    41 ms    29 ms  500.Serial1-3-3-17-0.GW6.GSO1.ALTER.NET [65.208.82.133]
  4    29 ms    29 ms    63 ms  0.ge-3-1-0.XL1.GSO1.ALTER.NET [152.63.41.94]
  5    37 ms    40 ms    41 ms  0.so-6-0-0.XL3.IAD8.ALTER.NET [152.63.0.138]
  6    61 ms    38 ms    38 ms  0.xe-3-3-0.BR1.IAD8.ALTER.NET [152.63.33.117]
  7    44 ms    45 ms    43 ms  te-11-3-0.edge1.Washington4.level3.net [4.68.63.169]
  8    42 ms    44 ms    43 ms  ae-1-69.edge1.Washington1.Level3.net [4.68.17.16]
  9    65 ms   101 ms    64 ms  GOOGLE-INC.edge1.Washington1.Level3.net [4.79.231.6]
 10   162 ms    46 ms    45 ms  209.85.240.136
 11    69 ms    69 ms    74 ms  66.249.95.149
 12    72 ms    69 ms   136 ms  209.85.254.241
 13    72 ms    82 ms    72 ms  209.85.253.141
 14    69 ms    72 ms    72 ms  yx-in-f100.google.com [74.125.45.100]

Trace complete.

TOP
How to open Command-line reference?
hh ntcmds.chm
TOP
How to show current directory?
echo %CD%
ie.lnk %cd%\Swing.html
TOP
How to create directory strucutre but no copying files?
XCOPY /T
/T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories.

/E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.
TOP
How to create folder and copy specified file at a time?
xcopy /i
/I If destination does not exist and copying more than one file, assumes that destination must be a directory.
TOP
How to find name and path of the batch file within the batch file?
name %0 and path %~dp0
TOP
What is ACL?
With respect to a computer filesystem, an access control list (ACL) is a list of permissions attached to an object. The list specifies who or what is allowed to access the object and what operations are allowed to be performed on the object. In a typical ACL, each entry in the list specifies a subject and an operation: for example, the entry (Alice, delete) on the ACL for file WXY gives Alice permission to delete file WXY.
XCOPY /o : Copies file ownership and discretionary access control list (DACL) information.
TOP
What is batch file?
A batch file is a text file containing a series of commands that you might ordinarily issue at the system prompt in order to perform a computer operation. The most common uses are to start programs and to run utilities. Batch files do that with one command instead of the multiple commands usually required
TOP