0% found this document useful (0 votes)
59 views

Module1-Command Shell 1

The document provides information about the Windows Command Shell and PowerShell. It discusses that the Command shell was originally used to automate tasks with batch files and scripts. Windows now has two command shells: the Command shell and PowerShell. The Command shell can only run Windows Commands while PowerShell can run both Windows Commands and PowerShell cmdlets, providing more capabilities. The document provides instructions on how to open the Command prompt and customize settings like the window size, fonts, and history. It explains how to use parameters to customize the default behavior when opening the Command shell.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Module1-Command Shell 1

The document provides information about the Windows Command Shell and PowerShell. It discusses that the Command shell was originally used to automate tasks with batch files and scripts. Windows now has two command shells: the Command shell and PowerShell. The Command shell can only run Windows Commands while PowerShell can run both Windows Commands and PowerShell cmdlets, providing more capabilities. The document provides instructions on how to open the Command prompt and customize settings like the window size, fonts, and history. It explains how to use parameters to customize the default behavior when opening the Command shell.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Module 1: Windows Command Shell

Module 1: Basic of the Command Line:


Windows Command Shell

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

Unit Learning Outcomes


At the end of this chapter, you will be able to:
a. Differentiate command and powershell;
b. Explain command shell; and
c. Explain power shell.

Topic 1. Types of windows command


Learning Objectives
At the end of this session, you will be able to:
a. Define what is command;
b. Distinguish different types of windows command;
c. Discuss each type of windows command; and
d. Illustrate the commands use for a particular computer task.

1
Presentation of Content

What is window command?

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.

How does a command line work?

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.

In general, the connection between operating system – regardless of whether


graphical (GUI = graphical user interface) or text-based (CLI = command line
interpreter) was condensed under the term “Shell.” The default command line
interpreter for Windows is called CMD.EXE. In addition, however, there’s also
the “PowerShell”: This offers more options than CMD.EXE. For example,
automations can be created better with PowerShell. In this way, users can create
script programs with the PowerShell scripting language.

How do you open the command prompt?

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.

Figure 1.1 The Windows Command Shell

The command interpreter executable, CMD.exe, is placed in the %SystemRoot%\System 32


folder.

In windows, the command shell window title will read C:\Windows\System32\CMD.exe. By


default the command shell starts in the use profile folder of the currently logged on user. That’s
why the current working directory is shown as C:\users\JHUN PACRIS>.

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.

Start a new CMD shell and (optionally) run a command/executable program.

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

Command : The command, program or batch script to be run.


This can even be several commands separated with '&'
(the whole should also be surrounded by "quotes")

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.

Customizing the Command Shell Window


The command prompt window has several properties that you can configure to
customize your working environment. For example, the window is 80 characters
wide and is 25 lines long by default. The characters are displayed in white over a
black background. You can set the cursor size, fonts, colors, and number of
commands in the command history, and whether the command shell should use a
small window or the full screen.
To change the default settings of the command shell, right-click the command
icon in the top left corner of the window and select Properties from the menu.
Module 1: Windows Command Shell

The Options Tab


The Options tab allows you to set the curson size, command history, display options, and editing
options, as shown in the Figure. You can choose from small, medium, or large cursor sizes. You
use the command history portion to set the number of commands that the command enterpreter
can remember. The number of buffers indicates how many separate histories are maintained. The
larger the commands you keep in the history, the more memory you will need. By default, there
are four buffers abd each buffer stores 50 commands. You can set these numbers at anywhere
from 0 to 999. If you are not sure how many buffers you will need, you should not change this
setting. You can choose to discard duplicate commands in the history to avoid unnecessary filing
up the buffer by repeating the same command.

Figure of the Options tab

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

The Layout Tab


You can change the layout of the command shell window from the Layout tab, as show in the
figure. The screen buffer size affects the size of the window and is set 80 x 300 by default. A
smaller screen buffer size lets you scroll through the window so that you can check previously
used commands and their outputs. Some scripts require a large screen buffer, but a buffer
setting of 1,000 by 1,500 would suffice in most cases. The combination of screen buffer size
and window height lets you view the executed command easily and scroll up and down the
command shell window. You can also set the window position to any corner of the screen, or let
windows manage the position automatically.
Module 1: Windows Command Shell

Figure of the Layout tab

The Colors Tab


The colors tab, shown in figure allows you to customize the colors of the command shell. You
can set the background and the text foreground to the color of your choice. You can also set the
background and text colors for pop-up windows. Usually, you select the colors from the color
bar and the resulting window is displayed at the bottom so that you can see how the command
shell window will look after the changes take effect. By changing the values of the red, green
and blue colors, you can fine-tune the selected color. These values range from zero to 255 for
each color.

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.

Internal Commands for the Command Shell


You can execute two types of commands from within the command shell. The first type is
internal command – these commands are built in the command shell itself and do not appear as
executable files anywhere in the system. Most of these commands are very similar to MS-DOS
commands. Examples of internal commands are Dir for generating a directory listing. Cls for
clearing the screen, and Del for deleting specific file.
Module 1: Windows Command Shell

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.

4. Date – Displays or changes the current date on the computer.

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.

8. Exit – Used to exit from the command shell window.

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.

11. If – Used in batch files to perform conditional processing of commands. If the


condition is satisfied, the command following the if command is processed.
Otherwise the interpreter processes the command that follows the Else
command.

12. Md – Creates a directory or a subdirectory. For example. Md


C:\Report\MyFiles will create a Myfiles subdirectory within the Reports
directory on the C: drive.

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.

16. Rd – Removes or deletes the directory or directories and subdirectories


specified in the command. The command cannot delete a directory that has
hidden or system files. You must empty the directory before using the
command, and you cannot delete the current working directory. You must first
use the Cd command to change the current directory.

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.

19. Time – Displays or changes the current time on the computer.


Module 1: Windows Command Shell

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:

Consider a command prompt property window displayed on-screen.

a. Determine the number of tabs seen in the properties window.


(1) What are their names?
b. Determine the dimension of the displayed command prompt window.
(1) Width
(2) Height
c. Determine the Font properties of the displayed command prompt window
according to.:
(1) Size
(2) Font
(3) Pixels wide
(4) Pixels high
d. Determine the Option properties of the displayed command prompt window
according to:
(1) Size
(2) Font
(3) Pixels wide
(4) Pixels high

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

a. Determine the number of tabs seen in the properties window.


The names are:
1.
2.
3.
4.
b.Determine the dimension of the displayed commad prompt window.
1. Width
2. Heigh

11

You might also like