- DOS commands are not case sensitive.
How to open DOS in Window XP/7/8.1/10 OS
(a) Press “Window key+r” – Type ”cmd or command” in box – ok.
OR
(b) Right click on Start button – Choose and click “Command prompt or command prompt(admin)”.[In window 10 OS]
NB: command prompt(admin) is used to open DOS in administrator mode.
Batch Command :
- The batch command is a recovery console command that executes a series of commands written within a file called Batch files.
- Batch files allow MS-DOS and Microsoft Windows users to create a list of commands to run in sequence once the batch file has been executed.
- A simple batch file does not require any special programming skills and can be done by users who have a basic understanding of MS-DOS commands.
- A good example of Batch file is use of Shortcut icon in Windows. Another very good example of Batch file is the use of Autoexec.bat file. (This is a boot batch file loaded each time the computer boots into MS-DOS and early versions of Windows. This batch file contained all the necessary commands and programs used to run MS-DOS and Windows each time the computer booted.).
- A batch file is executed in two ways – By command prompt and double click on the batch file.
- Batch files are created through two ways –
- Using MS-DOS:
A basic batch file is created using MS-DOS, the following steps are taken to create –
- Open MS-DOS.
- Create a new batch file by typing the name of file as edit test.bat at the MS-DOS prompt and then type press enter.
- Now, type the require commands:
pause
dir c:\windows
dir c:\windows\system
- Now, save the file again.
- Once we are back at the MS-DOS prompt(C:\), type: test and press enter. (This will execute the test.bat file and begin running the file. Because the first line is pause, we will first be prompted to press a key. Once we press a key the batch file will run line-by-line; in this case, listing the files in the windows and windows\system directories occurs.)
NB : Some versions of MS-DOS and bootable diskettes may not have the edit command; if this the case, we would either need to obtain the edit.com file to access this file or use the copy con command to create a new file.
- Using MS-Windows:
A Windows user can use any simple text editor, such as Notepad, to create/save batch files with file extension .bat. For this, we should follow the below steps –
- Open Notepad.
- Once notepad is open, type the commands in the file
@echo off
echo Batch file is started executing
pause
dir c:\windows
- Save the file as “test.bat”, and choose “Save as type” option, as “All files”, otherwise it will save as a text file. Once all of this has been done click the Save button and exit notepad.
- Now, to run the batch file, by double-clicking on it or run the file like any other program. Once the batch file has completed running it will close the window automatically.
NB: Here, @ symbol avoids echo back the text after the at symbol. This most commonly used as @ECHO OFF to prevent any of the commands in the batch file from being displayed, just the information needed.
In batch file, CALL statement is used to run another batch file within a batch file. When the batch file that is called is completed, the remainder of the original batch file command is completed. And if the called batch file does not exist it will give an error message.
Chdir/Cd Command :
- This command is used to change/switch and display the current directory.
- Example:
- CD directory_name command is used to move to the new directory ahead from current working directory.
- CD.. command is used to move to the one directory back in one go (i.e., in parent/root directory) from current working directory.
- CD/ command is used to move to the beginning or first directory back (i.e., in root directory) from current working directory in one go.
- cd /d command is used to switch from one drive to another drive in one go such as c:\cd / e:\new folder5 to move from c drive to new folder5 directory of e drive in one go.
Chkdsk command :
Cls command :
- This command is used to clear/clean the complete previous contents of the screen and leave only a prompt.
Syntax & Example:
C:\ cls (Press enter)
Copy Command :
- This command is used to copy a complete file from one location to another.
- Syntax:
C:\ copy source_file_name destination (press enter)
C:\ copy file1.txt d:\new folder (press enter)
C:\ copy *.txt f:\new folder1 (press enter)
Copy Con command :
- Copy con command is used to write/create a new or fresh file with certain name in the current/working directory.
- After the finishing of new file creation, CTRL+ Z button is pressed/required to save & exit from the created file successfully to come again at DOS prompt.
- This command actually copies the contents from the console and writes into a file.
- This command does not edit the created file.
- Syntax :
C:\ Copy Con Filename (Press enter)
C:\ Copy Con File1.txt (Press enter)
——–
——–
———
Ctrl+Z (to save & exit)
Date Command :
- The date command can be used to display the current date of the system and prompt for a new one. If no date is entered, the current date will be kept.
- This command is also used to change the date to an alternate date.
- C:\ date (Press enter)
- C:\>date
The current date is: 30-12-2022
Enter the new date: (dd-mm-yy)
Dir Command :
- This command is used to display all the non-hidden files & sub-directories present/stored in that current/working directory.
- In another words, this command is used to view the contents of a directory (directory list=files & directories).
- Syntax :
C:\ dir (Press enter)
C:\dir/option Directory_name (Press enter)
(i) C:\ dir (Press enter) [Display all the non-hidden files & sub-directories only from C drive/directory.]
(ii) D:\ dir (Press enter) [Display all the non-hidden files & sub-directories only from D drive/directory.]
(iii) C:\ New Folder\New Folder1\dir (Press enter) [Display all the non-hidden files & sub-directories only from New Folder1 directory.]
(iv) C:\ dir New Folder (Press enter) [Display all the non-hidden files & sub-directories only from New Folder directory of C drive.]
(v) C:\dir *.exe = To display or list all the non-hidden executables files from C drive.
(vi) C:\dir *.txt *.docx = To display or list all the .txt and .docx extension files from C drive.
- There are several options used with dir command to display the contents according to the need. These are –
- dir/a = Used to display all the hidden and non-hidden files & directories from that current/working directory.
- dir/ah = Used to display all the hidden files & directories only from that current/working directory.
- dir/a-d = Used to display all the files only from that current/working directory.
- dir/ad = Used to display all the directories only from that current/ working directory.
- dir/a/s = Used to display all the directories with files and sub-directories from that current/working directory.
- dir ra*.* = Used to display all the files & directories starting with ra alphabets having any extension name from that current/working directory.
- dir /s = List the files in the directory that we are in and all sub directories after that directory.
- dir /p = List all the files’ contents page wise.
- dir /w = List the file and directory related information width wise/horizontally.
- dir /s /w /p = List all the files and directories in the current directory and the sub directories after that, in wide format and one page at a time.
- dir /on = List the files in alphabetical order by the names of the files.
- dir /o-n = List the files in reverse alphabetical order by the names of the files.
- dir \ /s |find “i” |more = To list all directories on the hard drive, one screen page at a time, and see the number of files in each directory and the amount of space each occupies.
Del (Erase) command:
- Del command is used to remove one or more files permanently from a directory.
- Syntax:
C:\Del filename (Press Enter)
- Example:
- C:\Del File1.txt (Press Enter)
- C:\Del *.txt (Press Enter)
DelTree command:
- Deltree command is used to remove a directory along with sub-directory and files, if any, in one go, permanently.
- Syntax:
C:\Deltree Directory_name (Press Enter)
- Example:
- C:\Deltree Dir1 (Press Enter)
Echo command:
- Echo command is used to display messages as we typed or turns command-echoing on or off.
- Syntax:
- ECHO [message]
- ECHO [ON | OFF]
- Example:
Edit command:
- Edit command allows a user to view, create, or modify the text files.
- Syntax:
- C:\Edit filename (Press Enter)
- Example:
- C:\ Edit File1.txt (Press Enter)
Exit command:
- This command is used to come out/close/exit from the DOS.
- It quits the command.com file.
- Example :
C:\ exit (Press enter)
Format command:
- This command is used to format the diskette and fixed disks drive.
- This command initializes the directory and file allocation tables.
- Syntax:
C:\ Format drive_name: (press enter)
Finger command:
- This command is used to view information about users logged onto a remote computer.
- This may include their e-mail address, full name, when last time user logged in, read their e-mail etc.
- Syntax:
C:\ finger -l user@ localhost (Press enter)
Help command:
- Help command is used to give the information about the given keyword from a MS-DOS prompt.
- Syntax:
or
- Example:
- C:\dir -help
or
C:\dir /? [Gives the full detail about dir command] - C:\help dir (Press enter)
- C:\help dir (Press enter)
- C:\help date (Press enter)
- C:\date /? (Press enter)
Hostname command:
- Hostname command is used to display the name of current Host.
- Syntax & Example:
Ipconfig command:
- ipconfig command is used verify a network connection or view network settings.
- Syntax & Example:
Mkdir or MD Command :
- This command is used to create a new & blank directory in the current working directory with unique name.
- Syntax:
C:\ mkdir directory_name(Press enter)
C:\ md directory_name(Press enter)
C:\ mkdir India (Press enter)
C:\ md India (Press enter)
More Command :
- More command is used to display information or file contents to be displayed one page at a time.
- Example:
- C:\dir | more (Press enter)
- C:\file1.txt | more (Press enter)
Move Command :
- This command is used to cut/move a complete file from one location to another.
- This command is also used in renaming the files, sub-directories and directories.
- Syntax:
- C:\ move source_file_name destination (press enter)
- C:\ move old_file_name new_file_name (press enter)
C:\ move file1.txt d:\new folder (press enter)
C:\ move *.txt f:\new folder1 (press enter)
Net Command :
- Net command is used to manage, set, view and determine network settings.
- Example:
- C:\net view (Press enter)
- C:\net config (Press enter)
Netstat Command :
- Netstat command is used to display the TCP/IP network protocols statistics and information.
- Example:
- C:\netstat (Press enter)
- C:\netstat -a (Press enter)
Ping Command :
- Ping command is used to determine whether the network is able to communicate with the network or not.
- Syntax:
- C:\ping IP_address/web_address (Press enter)
Prompt Command :
- Prompt command is used to change the MS-DOS prompt letter.
- Syntax:
- C:\prompt normal_text (Press Enter)
- Example:
- C:\prompt raj (Press Enter)
- raj_
- Some special characters are not used as prompt using normal characters rather it is used specifically such as for –
- equal sign(=) use $Q.
- dollar sign ($) use $$
- Current time use $T
- Current date use $D
- Current drive use $N
- Pipe symbol (|) use $B
- Greater than symbol (>) use $G
- Smaller than symbol (<) use $&
- Type PROMPT without parameters to reset the default prompt again.
RM command:
- Remove command is used to remove files permanently from a directory.
- This command works similar as Del/Erase command.
- Syntax:
C:\rm filename (Press Enter)
- Example:
- C:\rm File1.txt (Press Enter)
- C:\rm *.txt (Press Enter)
Rmdir/RD Command :
- This command is used to remove a blank directory from the root/parent/current working directory.
- Syntax:
C:\ rd directory_name(Press enter)
C:\ rd folder1(Press enter)
Ren/Rename Command :
- Ren command is used to rename files and directories from the original name to a new name.
- Unlike the move command, this command cannot be used to rename sub-directories or rename file across drivers or cannot specify a new drive etc.
- Syntax:
- C:\ren directory_name or File_name (Press enter)
- Example:
- C:\ ren raj raj1 (press enter)
- C:\ ren *.txt *.bak (press enter)
- C:\ ren file1.txt file2.txt (press enter)
Sfc Command :
- Sfc command scans all protected system files and replaces incorrect versions with correct Microsoft versions.
- This is a great command to run when we are running into an issue that is difficult to troubleshoot.
- Syntax:
- Example:
- C:\ sfc (press enter)
- C:\ sfc /SCANNOW (press enter) [Scans all protected system files immediately.]
- C:\ sfc /SCANONCE (press enter)[Scans all protected system files once at the next boot.]
- C:\ sfc /SCANBOOT( press enter) [Scans all protected system files at every boot.]
Systeminfo Command :
- This command displays the complete system information for installed OS and network hardware used in our computer.
- Syntax & Example:
- C:\ Systeminfo (press enter)
Time Command :
- Time command is used to allow the user to view and edit the computer’s time.
- Syntax:
- Example:
- C:\time (press enter)
The current time is: 11:12:49.96
Enter the new time:
Title Command :
- Title command enables a user to change the title of their MS-DOS window i.e., sets the window title for the command prompt window.
- Syntax:
- C:\Title String (press enter)
- Example:
- C:\ Title Window DOS (press enter)
Tree Command :
- Tree command is used to allow the user to view a listing of files and folders in an easy-to-read listing mode.
- It usually lists in tree form of the current drive files and folders.
- To stop the Tree view in the middle of the screen, press Ctrl+C.
- Syntax:
- C:\Tree Drive_letter (press enter)
- Example:
- C:\Tree (press enter)
- D:\Tree (press enter)
Type Command :
- Type command allows the user to see the contents detail of a file.
- Syntax:
- C:\Type filename (press enter)
- Example:
- C:\Type file1.txt (press enter)
- C:\Type D:\file2.txt (press enter)
Ver Command :
- Ver command is used to displays the version of MS-DOS or if running Windows 95 or above the version of Windows.
- Syntax:
- Example:
Vol Command :
- Vol Command is used to display the volume information about the designated logical drive.
- Syntax:
- Example:
- C:\vol (press enter)
Volume in drive C is WIN 10 OS NEW
Volume Serial Number is K2E7-X516
Xcopy Command :
- Xcopy Command is used to copy one or more files and directories including sub-directories from one location to another.
- Syntax:
- C:\Xcopy sourcefile destinationfile (press enter)
- Example:
- C:\Xcopy c:\dirname1 d:\ (press enter)
0 Comments