BOOTCFG

BOOTCFG command Configures, queries, or changes Boot.ini file settings.

The bootcfg command is a Recovery Console command used to build or modify the boot.ini file, a hidden file that is used to identify in the location of Windows Installation.

Syntax

bootcfg [Parameter_1] [Parameter_2]

Parameter_1

/Query Displays the current boot entries and their settings.
/Copy Makes a copy of an existing boot entry.
/D The description of the OS entry being made.
/ID Specifies the boot entry id to be copied in boot.ini
/Rebuild This switch will rebuild the Boot.ini file.
/Delete Deletes an existing boot entry from the BOOT.INI file.
/ID Specifies the boot entry id to be deleted from boot.ini
/Addsw Allows the user to add predefined switches.
/SO Display the name of each device driver while loading.
/NG Disables the Windows progress bar that appears before the logon prompt.
/MM Specifies the amount of RAM (in MB) the OS can use.
/BV OS to use standard VGA mode for the installed video driver.
/ID  Specifies the boot entry id to add
/Timeout Allows the user to change the Timeout value.
/Default Allows the user to change the Default boot entry.
/ID  Specifies the boot entry id to be made as default
/Rmsw Allows the user to remove predefined switches.
/SO Removes the /sos switch.
/NG Removes the /noguiboot switch.
/MM Removes the /maxmem switch.
/BV Removes the /basevideo switch.
/ID Specifies the boot entry id to Remove.

/Dbg1394

Allows the user to configure 1394 port for debugging.
/CH Specifies the channel. Valid values: 1 to 64
/ID Specifies the boot entry id to change.
/Debug Allows the user to specify the port and baud rate for remote debugging.
/PORT Specifies the COM port to connect for debugging
/BAUD Specifies the baudrate to be used
/ID Specifies the boot entry id to add
/EMS Allows the user to configure the /redirect switch for headless support.
/PORT Specifies the COM port to connect for redirection
/BAUD Specifies the baudrate to be used for redirection

 Parameter_2

/s   Computer Name or IP address of a remote computer. Default is local computer.
/u   Domain\User  Runs the command with the account permissions of the user. Default is the permissions of current logged on user.
/p   Password Password of the user account used with /u switch.

Note:
BOOT.INI is used for boot options on Windows XP and earlier operating systems.  Use the BCDEDIT command line tool to modify Windows Vista boot options.

Example…
If you want to rebuild the boot.ini file below is a command.
Bootcfg /Rebuild

Display Boot Loader settings
bootcfg /query

Output:
Boot Loader Settings
——————–
timeout: 30
default: multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
Boot Entries

————
Boot entry ID:   1
Friendly Name:   “Microsoft Windows XP Professional”
Path:            multi(0)disk(0)rdisk(0)partition(1)\WINDOWS

PATH Command

Path Command to set the PATH of evnironment variable.

Path Command will add the path to environment variable which system used to search for executable files. When we run a command without providing a command location it first search at the location set to environment variable.

Syntax

Path Pathname
Path ;
Path

Parameters.

Pathname Specifies the drive and directory to set the path
; Specifies Separates directories
%path% Specifies Windows XP to append the command path to the existing set of directories listed in the PATH environment variable.

Example…

Path command will add Temp directory to look in for executable file and will remove existing paths to the current command prompt only.
Path C:\Temp

This below path command will clear the path to the current command prompt.
Path ;

Merge C:\temp path including the path already added.
Path = %path%; C:\temp

When you include %path% in the syntax, Cmd.exe replaces it with the command path value found in the PATH variable

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

You might have some files in the same directory that share the same file name but have different extensions. For example, you have Inventory.Exe to create network inventory, Inventory.bat to create Disk inventory in your network.

Operating system searches for a file in the following order: .exe, .com, .bat, and .cmd..

Findstr

Searches for patterns of text in files using regular expressions.

 

Syntax

findstr [Options] [Parameter_1] [Parameter_2]

Options

/p  Skips files with non-printable characters.
/b  Matches the pattern if at the beginning of a line.
/o   Prints seek offset before each matching 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 you use /l.
/s  Searches for matching files in the current directory and all subdirectories.
/m  Prints only the file name if a file contains a match.
/i   Specifies that the search is not to be case-sensitive.
/n  Prints the line number before each line that matches.
/x    Prints lines that match exactly.
/v   Prints only lines that do not contain a match.

Parameter_1

/f: file Reads file list from the specified file.

Parameter_2

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

Findstr is capable of finding the exact text you are looking for in any ASCII file or files. Sometimes you have only part of the information you want to search. findstr has capability to search for patterns of text using regular expressions.

Regular Expressions

. 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
[xy] Range: any characters within the specified range
\x Escape: literal use of metacharacter x
\<xyz Word position: beginning of word
xyz\> Word position: end of word

Examples

Use spaces to separate multiple search strings. To search for “hello” or “here” in file xyz.txt
findstr “hello here” xyz.txt

To search every file in the current directory and all subdirectories that contained the word Table and ignores the case sensitive.
findstr /s /i Table *.*

To search all occurrences of lines that contain the word “HELLO, and include the line number where each occurrence is found.
findstr /b /n /c:” *HELLO” *.txt

DiskPart

DiskPart command to manage Disks

DiskPart is a text-mode command to manage disk from command prompt, there are various action can be performed from command.

Syntax

Diskpart

SELECT Select an object (DISK, PARTITION, VOLUME, VDISK)
Example to select object number (0,1,2…)
Select Disk 0
Select Partition 0
Select Volume 0
Select Vdisk 0
LIST List an object (DISK, PARTITION, VOLUME, VDISK)
Example…
List Disk
List Partition
List Volume
List Vdisk
DETAIL Provide details about an object.
Example…
Detail Disk
Detail Partition
Detail Volume
Detail Vdisk
ACTIVE Selected partition will be marked as active.
ADD Add a mirror to a simple volume
ASSIGN Assign a drive letter.
ATTRIBUTES Display selected Disk or Volume attributes.
Example…
Attributes Disk
Attributes Volume
ATTACH Attaches a virtual disk file.
AUTOMOUNT Enable and disable automatic mounting of basic volumes.
BREAK Break a mirror set.
CLEAN Clear the configuration information, or all information, off the disk.
COMPACT Attempts to reduce the physical size of the file.
CONVERT Convert between different disk formats.
CREATE Create Volume
Example…
Create Volume Raid
Create Volume Simple
Create Volume Stripe
Create Volume Mirror
Create Partition EFI
Create Partition Extended
Create Partition Logical
Create Partition MSR
Create Partition Primary
Create Vdisk File=”filename”
DELETE  Delete an object.
DETACH  Detaches a virtual disk file.
EXIT  Exit DiskPart.
EXTEND  Extend a volume.
EXPAND  Expands the maximum size available on a virtual disk.
FILESYSTEMS  Display current and supported file systems on the volume.
FORMAT  Format the volume or partition.
IMPORT  Import a disk group.
INACTIVE  Mark the selected partition as inactive.
ONLINE  Online an object that is currently marked as offline.
OFFLINE  Offline an object that is currently marked as online.
REMOVE  Remove a drive letter or mount point assignment.
REPAIR  Repair a RAID
RESCAN  Rescan the computer looking for disks and volumes.
SAN  Display or set the SAN policy for the currently booted OS.
SHRINK  Reduce the size of the selected volume.

chkntfs

Chkntfs command to display a scheduled of automatic system checking

CHKNTFS modifies the behavior of the Autochk program, run at boot-time, to prevent CHKDSK from running automatically if Windows automatically schedules it, Displays whether automatic system checking is scheduled to be run on a FAT, FAT32, or NTFS volume when the computer is started. This utility works with ChkDsk to ensure your system remains problem free and sets up your drive to use chkdsk during the boot process , rather than after windows has booted, to ensure utility can gain full access to the drive.

Syntax

chkntfs drive:
chkntfs /d

Drive: Specifies the drive letter, Displays a message that identifies the file system of the specified volume.
/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 (in seconds). If you do not specify time, /t option displays the current countdown time
/x drive: Excludes the specified drive from being checked when the computer starts.
/c drive: Schedules the specified drive to be checked when the computer starts.

You must be a member of the Administrators group, to run chkntfs. You can set the Autochk.exe countdown time to zero.

Examples

Command to display the Autochk.exe initiation countdown time.
chkntfs /t

Command to change the countdown time to 20 seconds.
chkntfs /t:20

Command to exclude both drives D: and E:
chkntfs /x D: E:

Command to Schedules the specified drive
chkntfs /c d:

Nslookup

Nslookup command to troubleshoot DNS issues.

Nslookup is a command line administrative tool that displays information which you can use to diagnose Domain Name System (DNS) infrastructure.

Syntax

Nslookup

Domain Name Display information about the host/domain NAME using default server
Domain_Name DNS As above, use DNS as server
help or ? Display information on common commands
Set OPTIONS 
All Display current server and host details
debug Display debugging information
nod2 Display exhaustive debugging information
defname append domain name to each query
recurse ask for recursive answer to query
search use domain search list
novc always use a virtual circuit
domain=NAME set default domain name to NAME
srchlist=N1[/N2/…/N6] set domain to N1 and search list to N1,N2, etc.
root=NAME set root server to NAME
retry=X set number of retries to X
timeout=X set initial time-out interval to X seconds
Type=X Set query type (ex. A,ANY,CNAME,MX,NS,PTR,SOA,SRV)
queryType=X same as type
class=X set query class (ex. IN (Internet), ANY)
msxfr use MS fast zone transfer
ixfrver=X current version to use in IXFR transfer request
server NAME set default server to NAME, using current default server
lserver NAME set default server to NAME, using initial server
finger [USER] finger the optional NAME at the current default host
root set current default server to the root
ls [opt] DOMAIN [> FILE] list addresses in DOMAIN (optional: output to FILE)
-a list canonical names and aliases
-d list all records
-t type list records of the given type (e.g. A,CNAME,MX,NS,PTR etc.)
view FILE sort an ‘ls’ output file and view it with pg
exit exit the program

Note

  • If ComputerToFind is an IP address and the query is for an A or PTR resource record type, the name of the computer is returned. If ComputerToFind is a name and does not have a trailing period, the default DNS domain name is appended to the name. This behavior depends on the state of the following set subcommands: domainsrchlistdefname, and search.
  • If you type a hyphen (-) instead of ComputerToFind, the command prompt changes to nslookup interactive mode.
  • The command-line length must be less than 256 characters.
  • Nslookup has two modes: interactive and noninteractive.

If you need to look up only a single piece of data, use noninteractive mode. For the first parameter, type the name or IP address of the computer that you want to look up. For the second parameter, type the name or IP address of a DNS name server. If you omit the second argument, nslookup uses the default DNS name server.

If you need to look up more than one piece of data, you can use interactive mode. Type a hyphen (-) for the first parameter and the name or IP address of a DNS name server for the second parameter. Or, omit both parameters and nslookup uses the default DNS name server. Following are some tips about working in interactive mode:

    • To interrupt interactive commands at any time, press CTRL+B.
    • To exit, type exit.

Example:

Nslookup Domain_Name

Display All details of Domain_Name
Nslookup
Set type = all
Domain_Name

More

Displays one screen of output at a time.

Syntax

Command | more
More /c /p /s /t

Key

Path\FileName  Specifies the file to display.
command  A command for which you want to display the output.
/E Enable extended features
/c  Clears screen before displaying page.
/p  Expands form-feed characters.
/s  Multiple blank lines squeeze to one blank line.
/t n  Changes tabs to the number of spaces specified by n.
+n  Displays first file starting from the line specified by n.
files  Specifies list of files to display. file names should be separated with a space.

If /E is used extended features will be enabled, the following keystrokes can be use with the — More — prompt

SPACEBAR Display next page
ENTER Display next line
f Display next file
q Quit
= Show line number
n Display next n lines
n Skip next n lines

Examples

To view the file named File.txt that you want to view on your screen, type
more < File.txt

The more command displays the first screen of information from File.txt, and then the following prompt appears:

— More —

You can then press the SPACEBAR to see the next screen of information.

To clear the screen before displaying File.txt, type

More /c < File.txt

The more command displays the first screen of information from File.txt, 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.

To display the current line number, type =. The current line number will be added to the more prompt

To display specific number of lines, type pMore prompts you for the number of lines to display as follows:

Move command

Move command to move one or more Files and Directory

Move command is functionality equivalent to copying a file or directory and erasing it from the current directory.

Syntax

Move Source Destination

 Key

/y     Will not prompt you weather to overwrite an existing destination file.
/-y    Prompts you to confirm to overwrite an existing destination file.
Source     Specifies the path and name of the file or folder. 
Destination  Specifies the path and name to move files or folder.

Note:

  • Using the /y command-line option
    The /y command-line option might be preset in the COPYCMD environment variable. You can override this with /-y on the command line. The default is to prompt on overwrite.
  • Moving encrypted files to a volume that does not support Encrypting File System (EFS) will give an error. Decrypt the files first or move the files to a volume that does support EFS.

Both Source and Target may be either a folder or a single file.

Example…

In the current folder
Move source_file.doc destination_file.doc

Move from a different folder/directory:
MOVE “C:\home\file1.doc” “D:\work\file2.doc” (Renamed file at destination)
MOVE “C:\home\file1.doc” “D:\work\file1.doc”

Specify the source only, with a wildcard will Move all the files into the current directory:
MOVE “C:\home\*.doc”

Copy Command

Copy Command in Windows.

Copy command in details to know how to copy one or more files from one location to another and merging two or more files into a single file.

Syntax

Copy Source_File Destination_File

/d  Allows encrypted files to be saved as decrypted files at the destination.
/v  Verifies destination 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  Will not prompt you weather to overwrite an existing destination file.
/-y  Prompts you to confirm to overwrite an existing destination file.
/a  Indicates an ASCII text file.
/b  Indicates a binary file.

Source_File: Specifies the location from where you want to copy a file or set of files.
Destination_File: Specifies the location where you want to copy a file or set of files.

Combining files
If you specify more than one Source, with a plus sign (+), copy command combines the files into a single file. If you use wildcard characters (that is, * or ?) in Source and specify a single file name in Destination, copy command combines all files matching the file name in Source and creates a single file with the file name specified in Destination

Example…

In the current folder
COPY source_file.doc destination_file.doc

Copy from a different folder/directory:
COPY “C:\home\file1.doc” “D:\work\file2.doc”

Specify the source only, with a wildcard will copy all the files into the current directory:
COPY “C:\home\*.doc”

Specify the source with a wildcard and the destination as a single file, generally used with plain text files.
COPY “C:\my work\*.txt” “D:\New docs\combined.txt”

Combining files
Copy c:\file1.txt + c:\file2.txt File3.txt

Copy silently (no feedback on screen)
COPY source_file.doc destination_file.doc >nul

CHKDSK

Chkdsk Command to check the health of Disk

chkdsk command to Display a status report of Disk and Repairs Disk related problems, produces a report that shows the the block /cluster size and Bad Sectors.

Syntax

CHKDSK [Drive:]

volume Specifies the drive letter Example. C:
filename FAT/FAT32 only, filename to check for fragmentation.
/F Fixes errors on the disk.
/V On FAT/FAT32: Displays the full path and name of every file on the disk.
/R Scan bad sectors and recovers readable information (implies /F).
/L:size Changes the log file size to the specified number of kilobytes. (NTFS only).
/X Forces the volume to dismount. All opened handles to the volume shall be invalid (implies /F).
/I Check of index entries. (NTFS only)
/C Skips corruption check within the folder
/B Re-evaluates bad clusters on the volume (implies /R)
The /I or /C switch reduces the amount of time required to run Chkdsk by skipping certain checks of the volume.

Example:

CHKDSK C: /F
CHKDSK D: /F

Fixing Errors /F
If the drive is the boot partition, you will be prompted to schedule the check during the next boot
Chkdsk /f will lock the volume/drive and data will not available until chkdsk is finished.
Chkdsk /f may take a long time to complete if there are large number of files (millions) stored.
Chkdsk command will scan only if /f switch is not added.

Run at Bootup
Running at bootup is often the easiest way to close all open file handles.

Cluster (or block) Size
CHKDSK produces a report that shows the the block /cluster size
Default: “4096 bytes in each allocation unit.”
NTFS compression functions are not available, when the cluster size is greater than 4 KB on an NTFS volume.