Monthly Archives: April 2011

Net Group

The Net group command allows you to add, display, or modify global groups in domains. The Net group command can also be used to add or remove users to a specified groups. When used with /comment attribute the Net group command allows you to add comments up to 48 characters long to your groups. See below for correct syntax and usage.

Syntax (view syntax formatting guide):

net group [GroupName [/comment:"Text"]] [/domain]
net group [GroupName{/add [/comment:"Text"] | /delete} [/domain]]
net group [GroupName UserName[ ...] {/add | /delete} [/domain]]

Syntax Explanation:

  • GroupName: Specifies the name of the group to add, expand, or delete. Specify a group name to view a list of users in a group only.
  • /comment:”Text“: Adds a comment for a new or existing group. The comment can have as many as 48 characters. Enclose the text in quotation marks.
  • /domain: Performs the operation on the domain controller in the current domain. Otherwise, the operation is performed on the local computer.
  • /add: Adds a group, or adds a user name to a group. You must establish accounts for users that you add to a group with this command.
  • /delete: Removes a group, or removes a user name from a group.
  • UserName[ …]: Lists one or more user names to add to or remove from a group. Separate multiple user names with a space.
  • net help <command>: Displays help for the specified net command.

Explanation with Examples:

This example lists all the groups on the local server:

net group

This example adds a group called Sales to the local user accounts database:

net group sales /add

This example adds a group called Sales to the domain database:

net group sales /add /domain

This example adds the existing user accounts sthomas, awiese, and khall to the Sales group on the local computer:

net group sales sthomas awiese khall /add

Net Computer

The Net computer command can be used to add or delete a computer from a domain database. The Net computer only works for the domain on which you are currently logged on to. Furthermore when you run the Net computer command from an administrative workstation all of the additions and deletions will be forwarded to the domain controller and domain level administration privileges will be required to complete the addition or deletion. This command only allows you to specify one computer at a time and you may not specify any other domain to which you are not logged on to.

Syntax (view syntax formatting guide):

net computer \ComputerName {/add | /del}

Syntax Explanation:

  • \ComputerName: Specifies the computer to add or delete from the domain database for the domain in which you are currently logged on. You can specify only one computer. You cannot specify other domains.
  • {/add | /del}: Adds or deletes the specified computer from the domain database.
  • net help Command: Displays Help for the specified net command.

Explanation with Examples:

The following example adds the computer Timmy to the domain database:

net computer \timmy /add

Nbstat

The Nbstat command is a great command to use when you need to display the NetBIOS over TCP/IP protocol statistics. The Nbstat command can also be used to display NetBIOS name tables for both local and remote computers. The Nbstat command can also be used to display the NetBIOS name cache, which will show you all of the NetBIOS names that have recently been associated with a specific IP address. When you use the -R and -RR attributes along with the Nbstat command you can refresh or purge the NetBIOS name cache (-R) and the names registered with WINS, Windows Internet Name Service, (-RR). The NetBIOS name cache helps to reduce network traffic by eliminate the need for broadcasting or long WINS queries.

Syntax (view syntax formatting guide):

nbstat[-aRemoteName][-AIPAddress][-c][-n][-r][-R][-RR][-s][-S][Interval]

Syntax Explanation:

  • -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 computer running Windows XP or a Windows Server 2003 operating system 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.

The following list describes the column headings that are generated by nbtstat.

  • 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 list describes the possible NetBIOS connection states.

  • 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.

Explanation with Examples:

To display the NetBIOS name table of a remote computer with the NetBIOS name of COMPUTER190, execute:

nbtstat -a COMPUTER190

To display the NetBIOS name table of aremote computer withthe IP address of 192.168.10.12, execute:

nbtstat -A 192.168.10.12

To display the NetBIOS name table of the local machine, execute:

nbtstat -n

To display the contents of the local computer NetBIOS name cache, execute:

nbtstat -c

To purge the NetBIOS name cache and reload the #PRE-tagged entries in the local Lmhosts file, execute:

nbtstat -R

To display NetBIOS session statistics by IP address every 10 seconds, execute:

nbtstat -S 10 


Compact

The compact command is used to compress data on NTFS volumes from the Windows Command Prompt or command line. It can also be used to display the current compression status of folders or files.

Syntax (view syntax formatting guide):

compact [/c | /u] [/s[:Dir]] [/a] [/i] [/f] [/q] [FileName[...]]

Syntax Explanation:

  • /c: Compresses the specified directory or file or the current directory if no directory is specified.
  • /u: Uncompresses the specified directory or file or the current directory if no directory is specified.
  • /s[:Dir]: Performs directory recursion. Applies the compact command to all subdirectories of the specified directory (or of the current directory if none is specified).
  • /a: Displays hidden or system files that may be compressed.
  • /i: Ignores any errors and continuess with the compression.
  • /f: Forces compression or uncompression of the specified directory or file. /f 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 instead of the default of verbose information.
  • FileName: Specifies the file or directory. You can use multiple file names, and the * and ? wildcard characters.
  • /?: Displays help at the command prompt.

Explanation with Examples:

To view the compression status of the current folder, execute this command:

compact

To compress all of the Microsoft Word documents in the current folder and all subfolders, execute this command:

compact /c /s *.doc

Syntax Formatting Guide for WindowsCommandLine.com

This document is a guide to the syntax representations shown here at WindowsCommandLine.com. It is intended to help you understand the syntax shown for each command.

The following example syntax statement, taken from the icacls command,  will be used to explain the  syntax elements you may see for a command:

icacls FileName [/grant[:r] Sid:<Perm>[...]] [/deny Sid:Perm[...]]
 [/remove[:g|:d]] Sid[...]] [/t] [/c] [/l] [/q]
 [/setintegritylevel Level:Policy[...]]

OR

icacls Directory [/substitute SidOld SidNew [...]]
 [/restore ACLfile [/c] [/l] [/q]]

The first parameter in the syntax is always the command itself. In this case, it is the icacls command. This command is used to manage permissions from the Command Prompt.

When you see italicized parameters, these represent variables. For example, the parameter FileName should be replaced with an actual filename and the parameter Directory should be replaced with an actual directory of folder name, such as:

icacls file1.txt

The preceding command would display the current permissions on the file named file1.txt.

Parameters inside of square brackets are optional. For example, with the icacls command, you can use the /t switch if you need it, but it is not required for the command to process.

When you see […], this indicates that you can repeat the previous parameter as often as needed in the command. For example, when using the icacls command to grant permissions, you can do so for multiple SIDs (security IDs) at the same time.

Comp

The comp command is used to compare the contents of two files at the Windows Command Prompt. This command line tool is often used to discover the differences between two files or to find duplicate files. Many people think that the Command Prompt in Windows is DOS, but it’s actually a Windows 32-bit application (on 32-bit Windows) or a Windows 64-bit application (on 64-bit Windows) that provides a text mode (command line) interface to the system. While you may have searched for DOS comp command, know that the instructions here are for the command you are seeking.

Syntax (view syntax formatting guide):

comp Data1 Data2 [/d] [/a] [/l] [/n=Number] [/c] [/?]

Syntax Explanation:

  • <Data1>: Specifies the name of the first file to be compared. Multiple files can be specified using wildcards (* and ?), such as QrtRpt*.rpt.
  • <Data2>: Specifies the name of the second file to be compared. Multiple files can be specified using wildcards (* and ?).
  • /d: By default, differences are displayed in hexadecimal encoded format. This switch changes the output to decimal format.
  • /a: Displays differences as characters instead of hexadecimal or decimal codes.
  • /n=Number: Compares the number of lines specified in each file. The comparison occurs even if the files are different sizes.
  • /c: Performs a case insensitive search. The default is a case sensitive search.
  • /?: Displays help for the command.

Explanation with Examples:

The comp command is mostly used with text files, but it may be used to compare binary files as well. Many different file types are actually stored as text, including:

  • HTML
  • RTF
  • XML
  • CSS
  • INI
  • TXT
  • CFG
  • NFO
  • ASP
  • PHP

In the examples presented here, two simple text files are used. They are named file1.txt and file2.txt. The following image shows their contents displayed using the type command from the Windows command line.

File1.txt and File2.txt Contents Displayed

File1.txt and File2.txt Contents Displayed

If you use the comp command to compare two files of different sizes, by default, it will simply inform you of the difference in size and will not perform further processing. However, you can use the /n switch to direct it to process the first few lines regardless of file size differences. The following image shows an example of the command comparing two files of different sizes, but inspecting only the first 2 lines and displaying the output as text with the /a switch as well.

Comparing Two Files with Limited Lines

Comparing Two Files with Limited Lines