Module1-Command Shell 1
Module1-Command Shell 1
Introduction
The Command shell was the first shell built into Windows to automate routine
tasks, like user account management or nightly backups, with batch (.bat) files.
With Windows Script Host you could run more sophisticated scripts in the
Command shell. You can perform operations more efficiently by using scripts
than you can by using the user interface. Scripts accept all Commands that are
available at the command line.
Windows has two command shells: The Command shell and PowerShell. Each
shell is a software program that provides direct communication between you and
the operating system or application, providing an environment to automate IT
operations.
PowerShell was designed to extend the capabilities of the Command shell to run
PowerShell commands called cmdlets. Cmdlets are similar to Windows
Commands but provide a more extensible scripting language. You can run
Windows Commands and PowerShell cmdlets in Powershell, but the Command
shell can only run Windows Commands and not PowerShell cmdlets. -
(https://docs.microsoft.com/)
1
Presentation of Content
The MS-DOS command shell was originally known as the DOS prompt.
Administration and users alike used to perform almost every operating system
task they needed to perform from DOS prompt – whether it was copying a file
from one directory to another, creating a directory, or setting the attributes of a
file. In addition, people used to write batch files directly from the DOS prompt,
and then save them and execute them from there.
The command line (also called the console or terminal) is a text-based interface
within the operating system, that forwards commands from the user to the
operating system. This makes it possible, for example, to organize files, start
programs, or run other commands linked to the operating system, computer, or
network.
In older operating systems (like MS-DOS), you had to work without a graphical
user interface, and oftentimes even navigate without a mouse. Instead, you had to
type in all commands – the directory structures were then displayed as plain text
on the screen. But even after the switch to graphical operating systems, the
command line remained text-based.
There are various options for accessing the command line in Windows.
Technically speaking, the command line is the CMD.EXE program. This
executable file should be found in the system directory of your Windows folder.
(If you right-click on the file, Windows also gives you the option to start the
program as an administrator – in case you have the access data for this.) To reach
the program more quickly, you can use the search bar or the run menu. The latter
is opened under Windows 7, 8, and 10 with the key combination Win + R. Then
all you have to do is type “cmd” into the search field and press the OK button.
Module 1: Windows Command Shell
Today, people refer to the DOS prompt as the MS-DOS command shell, and it still exist in all
version of windows.
You can access the MS-DOS command shell from the Run dialog box as follows:
1. Select “Type here to search” and type “command” in the textbox provided.
2. Press Enter.
This starts the MS-DOS command shell. You will notice the words “Microsoft Windows” in the
window. The window has dark background. To properly close the MS-DOS command shell,
you must type exit and press Enter.
A blinking cursor following the command prompt indicates that it is interactive mode. This
mode allows you to enter the commands directly at the prompt and press the Enter key to
execute them. For example, if you type the command Dir at the command promt and press the
Enter key, the command will execute immediately and the results will appear in the window.
3
Customizing the Command Shell Startup
As we discussed earlier, you can start the command shell either from the Run
dialog box or from Accessories in the program menu. This starts the interpreter
in its default mode. You cn customized the default behavior of the CMD.exe
interpreter using a numer of available parameter or switches. Changing the
default effects the application or other commands you run inside the command
shell.
Syntax
CMD [charset] [options]
CMD [charset] [options] [/C Command]
CMD [charset] [options] [/K Command]
Options
/C Run Command and then terminate
/K Run Command and then return to the CMD prompt.
This is useful for testing, to examine variables
REMINDERS:
Do not use some variables together. For example, if you are using /A, you cannot
use /U at the same time.The commands you use at the command prompt in
windows are not case sensitive. You do not worry about the Caps Lock key when
you are typing commands.
Reminders:
You can use Quick Edit Mode or Insert Mode when editing commands. Use Quick Edit mode
when you want to use the mouse to edit entries. Insert Mode works by inserting text without
overwriting the existing text in a line. For example, if you want to copy a line from another
application and paste it directly into the command line, you can use Insert Mode.
5
The Font Tab
The Font tab allows you to choose a font and its size, as shown in the figure. These options let
you control the size of the text within the command. The default font is 12-point Lucida
Console. With Raster fonts the size of the window automatically changes when you change the
font size. You can also make the fonts appear in boldface.
Figure of the Font tab
7
Figure of the Colors tab
Reminders:
When you finish changing the properties of the command shell, click OK. A small Apply
Properties dialog box will prompt you to select how the changes should take effect.
The second type of command you can execute from within the command shell is an external
command. External commands are separate executable files located in the
%SystemRoot\System32 folder. Although these are called external, they still run from within the
command shell. Examples of external commands are XCOPY.exe for copying the entire
directory tree, DISKPART.exe for managing disk partitions, and IPCONFIG.exe for displacing
the computer’s transmission control protocol/internet protocol (TCP/IP) configurations. External
commands are more versatile and offer more advanced capabilities than internal commands.
Here is a list of all internal commands of DOS/CMD in Windows.
1. CD – Displays the name of the current working directory or changes the current working
directory. If you use it without any parameters, the current working directory is displayed.
For example, to change the working directory to C:\Adminfiles\Support, assuming your
current working drive is C:, type cd\adminfiles\support at the command prompt.
2. Color – Changes the foreground and background colors for the current session of the
command shell. This command has the same effect as using cmd /t:FB . The parameter F and
B are values of the colors.
3. Cls – Clears the screen of the current command shell and erases the screen buffer, resulting
in a blank command prompt window.
5. Dir – Displays the contents of the current working directory, including names of the
subdirectories. You can specify a different directory and use wildcards to limit the results.
This command also displays the total number of files and subdirectories, their size, total
space used, and space remaining on the drive.
6. Del (Erase) – Deletes the specified file, multiples files, or all files within a given directory.
For example the command Del C:\Reports will delete all files in the C”\Reports folder. You
can use wildcards to specify certain types of files to delete; For example, Del
C:\Reports\*.doc will delete all files with a .doc extension in the C:\Reports folder.
7. Echo – Displays text strings used with the command line and sets the echo on or off. You
can also use the command to display a message.
9. For – Used to run a specified command for each file in a set of files. You can use it within a
batch file or directly from the command prompt.
9
10. Goto – Used to direct the command interpreter to jump to a command
specified with the label. You use it in batch files to direct the processing from
the command indentified by the label.
13. Move – Moves one or more files from one directory to another. The source
and target locations of the files are specified in the command. If the source is
not specified, files are moved from the current working directory.
14. Pause – Suspends the processing of a batch file and prompts the user to press
any key to continue processing. Using pause in a batch file is different from
using the Ctrl + C key combination. The key combination stops the batch
program from processing and asks the user if they want to terminate the
procedure.
15. Prompt – Sets the display text for the command prompt. You use it to
customize the command prompt to display any text, such as the current date
and time. To reset the prompt to its default, use the Prompt without any
parameters.
17. Rem – Used to insert comments or remarks in a batch file. The text after the
Rem command is not processed.
18. Start – Opens a second command prompt window to run a specified program
or an executable. If no program or command is specified, the command just
open another command prompt window.
20. Title – Used to change the title of the command prompt window during the processing of a
batch file. You can reset the title to its default by using the Title command again.
21. Vol – Displays the volume number and serial number of a disk.
Application
Answer the following:
Prepare the copy of your answer in any word processing app using the following
format:
Name : ____________________________
Subject : System Administration and Maintenance
Activity 1 : Windows Command Shell
11