CLS: Clears the screen.


 


... The examples for the command "CLS"
... "CLS" Excerpt from Microsoft Windows Help
... Important information, tips for the "CLS" command

The command: "CLS" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available

The examples for the command "CLS"

The `CLS` command in the Windows Command Prompt is used to clear the screen and clean the console. Here are some examples with comments: Example 1: Simple screen clearing:

CLS

Description: This command clears the screen and displays a blank console. Example 2: Using CLS in a batch script:

@ECHO OFF
REM Some commands are executed here
ECHO This is an example text.
REM Clear the screen
CLS
REM Continuation of the script
ECHO This is after clearing the screen.

Description: Here `CLS` is used in a batch script to clear the screen. This can be useful to make the script's output cleaner. Example 3: Combining CLS with the `PAUSE` command:

CLS
ECHO Welcome to the Windows Command Prompt.
BREAK

Description: This example clears the screen, then displays a welcome message, and finally pauses execution with the `PAUSE` command to give the user time to read the message. Example 4: Using CLS in an infinite loop:

:Ribbon
ECHO The screen clears every 5 seconds.
TIMEOUT /T 5 /NOBREAK > ZERO
CLS
GOTO loop

Description: Here the screen is cleared in an endless loop every 5 seconds. The `TIMEOUT` command causes the script to pause for 5 seconds. Example 5: Using CLS in a PowerShell script:

Write-Host "This is a PowerShell message."
Start-Sleep-Seconds 3
Clear host
Write-Host "The screen has been erased."

Description: This example uses `Clear-Host` in a PowerShell script to clear the screen. This is the PowerShell equivalent of `CLS`. The `CLS` command is simple but useful for cleaning up the console and cluttering up the output, especially when interacting with batch scripts or the command prompt.

"CLS" Excerpt from Microsoft Windows Help

Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.

C:\\WINDOWS>

Clears the screen.

CLS

Important information, tips for the "CLS" command

There are a few things to keep in mind when using the `CLS` command in the Windows Command Prompt: 1. Loss of information: `CLS` clears the screen and previous command output. Make sure that the users or script participants no longer need the previous output, as it cannot be restored after calling `CLS`. 2. Not memory intensive: The `CLS` command is not memory intensive and has no lasting effect on the system. It only affects the display in the current command prompt session. 3. No Impact on File System: `CLS` does not affect the file system or data on the drive. It is a purely visual command that cleans up the display in the console. 4. Non-suppressible: There is usually no option in the command prompt to suppress screen clearing by `CLS`. It will be executed immediately and without confirmation. 5. Use in batch scripts: In batch scripts, using `CLS` can be useful to structure and organize the output. However, note that this will result in previous editions no longer being visible. 6. Combination with other commands: `CLS` can be combined with other commands to make the console more interactive or clearer. For example, it can be used with `ECHO` to mark clear sections in a script.

ECHO #######################
ECHO # This is a section #
ECHO #######################
CLS

7. Usage in PowerShell: In PowerShell, `Clear-Host` is often used instead of `CLS`. The functionality is similar, but PowerShell commands often have their own preferences and options.

Clear host

8. Display Warnings: Note that quickly clearing the screen through `CLS` may cause users or script participants to miss information. If important information is displayed before clearing the screen, it might be useful to alert the user.

ECHO Attention: The screen will be deleted.
BREAK
CLS

Overall, `CLS` is a simple console cleanup command that can usually be used without any problems as long as the above considerations are taken into account.


Deutsch
English
Español
Français
Italiano
日本語 (Nihongo)
한국어 (Hangugeo)
汉语 (Hànyǔ)
Türkçe
Português
Português
Svenska
Norsk
Dansk
Suomi
Nederlands
Polski









Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



The command CLS - Clears the screen.

HTTP: ... console/en/012.htm
0.093
8434
Preview PDF files of Adobe and other Images from Explorer views?
How can i start with a favorite setting for explorer views from Desktop?
Die Adressleisten Regeln der Explorer Ansichten, fast wie in MS Windows Explorer!
Can I install Windows 11 on Virtual Box?
Das Explorer Spaltenchaos - Eine unendliche Geschichte?
Keyboard shortcuts window customize under Windows, with examples!
What is the difference between memory and hard disk space?
Beim Filtern zum markierten Objekt / Dateien scrollen, bzw. springen?
Kann ich bei der Modernen Adressleiste sehr lange Verzeichnisnamen editieren?
What is Alt-Gr for a key?



(0)