How to Clean Your Windows PC Using the Command Prompt

Trending 3 weeks ago

Key Takeaways

  • Command Prompt is simply a useful instrumentality for cleaning up your Windows computer, offering ratio and capacity benefits.
  • Command Prompt tin defragment your difficult disk, improving publication and constitute velocity and wide strategy performance.
  • The Disk Cleanup instrumentality tin beryllium accessed and customized utilizing Command Prompt, allowing you to delete circumstantial types of files.

Keeping your machine free from clutter tin thief amended capacity and free up tons of retention space. Windows has respective built-in strategy cleanup utilities, including nan Disk Cleanup tool. However, nan Command Prompt is simply a lesser-known measurement to cleanable your computer.

Here are a fewer ways to cleanable up a slow Windows machine utilizing Command Prompt.

Why Clean Up Your Computer Using nan Command Prompt?

Command Prompt is simply a built-in bid processor disposable connected almost each Windows versions since Windows 3.1. While nan graphical personification interface is useful for astir people, immoderate whitethorn for illustration nan Command Prompt to execute respective tasks for its ratio and capacity benefits.

If you are caller to Microsoft’s celebrated bid processor, cheque retired our beginner’s guideline to nan Windows Command Prompt.

The Disk Cleanup instrumentality and nan Storage Sense characteristic successful Windows 11 make it reasonably easy to cleanable up your computer. If immoderate unwanted files remain, you tin region them manually by, for example, clearing your temp folder. You tin velocity up this process pinch nan thief of commands to entree nan Disk Defragmenter, diskpart, and nan Disk Cleanup tool.

Start Cleaning Your Computer Using CMD

Below is nan database of commands to motorboat nan disk cleanup utility, cleanable impermanent files, representation cache, and more.

Some of these commands whitethorn require you to unfastened Command Prompt arsenic administrator. Here’s really to do it.

  1. Type cmd in nan Windows hunt bar.
  2. Right-click connected Command Prompt and select Run arsenic administrator.

How to Defragment Hard Disk With nan Command Prompt?

While disk fragmentation connected accepted difficult disks is natural, it tin origin capacity issues. It affects your disk's publication and constitute speed, making your strategy slow.

The Windows Command Prompt successful nan process of defragmentation, showing measurement accusation and nan expected results

Defragmentation rearranges fragmented information to thief your disks activity much efficiently. You don’t request to defragment your SSD retention devices (nor is it recommended). But if you usage a mechanical difficult drive, here’s really to defragment nan difficult disk pinch a command.

  1. Open nan Command Prompt arsenic administrator.
  2. In nan Command Prompt, type nan pursuing bid and deed enter: defrag c:
  3. In nan supra command, c: is nan thrust you want to defrag. Change nan thrust missive if you want to defrag different drive.

You tin tally nan defrag bid pinch optional switches. Check Microsoft's archiving connected utilizing nan defrag command for much penetration into utilizing different syntax pinch nan defrag bid to execute analysis, adhd exceptions, alteration priority, and more.

Quick Disk Cleanup Using nan Run Box

disk cleanup utilizing tally command

You tin usage a Run bid to execute a speedy disk cleanup without opening nan Command Prompt. It is useful if you want to free up a fewer gigabytes of retention successful 2 steps. This requires you to commencement nan Disk Cleanup instrumentality and specify nan disk you want to cleanable via nan Run dialog.

To tally Disk Cleanup:

  1. Press Win + R to unfastened Run.
  2. Type nan pursuing bid successful nan Run dialog: C:\windows\SYSTEM32\cleanmgr.exe /dDrive
  3. In nan supra command, switch Drive with nan disk thrust missive you want to clean. For example, if you want to execute a speedy cleanup for nan E drive, past nan afloat bid will look for illustration this: C:\windows\SYSTEM32\cleanmgr.exe /dE
  4. Click OK aliases property Enter to execute nan command.
  5. Run will quickly motorboat nan Disk Cleanup instrumentality pinch your specified thrust selected.
  6. Select nan files to delete and click OK.

How to Use nan Disk Cleanup Utility via Command Prompt

Disk Cleanup is simply a built-in Windows inferior to thief you free up abstraction connected your computer’s difficult drive. It tin cleanable up downloads, impermanent net files, recycle bin, and moreover strategy files.

You tin usage nan Command Prompt to motorboat Disk Cleanup and execute automated cleanup tasks directly. Here is really to usage nan instrumentality and supported command-line switches.

Basic File Deletion

The Windows Disk Cleanup program, a GUI app launched from a bid prompt

You tin usage nan cleanmgr command to motorboat nan Disk Cleanup instrumentality utilizing Command Prompt.

  1. Open Command Prompt, type cleanmgr, and deed Enter.
  2. In nan Drive Selection window, prime nan thrust you want to cleanable up and click OK.
  3. In nan Disk Cleanup window, prime each nan files you want to delete and click OK.
  4. Click connected Delete Files to corroborate nan action.

Clean Up a Specific Drive/Partition

cleanmgr circumstantial drive

You tin usage nan cleanmgr bid followed by a thrust missive to tally nan Disk Cleanup instrumentality against that drive. This is useful to free up abstraction connected a circumstantial drive. For example, tally nan pursuing bid to tally nan Disk Cleanup instrumentality against nan C drive:

cleanmgr /D C

The Disk Cleanup instrumentality will scan and show each nan files you tin delete. Make your action and click OK.

Configure nan Disk Cleanup Tool Settings

To customize nan Disk Cleanup instrumentality settings, nan cleanmgr bid supports aggregate switches, including sageset and sagerun.

  • sageset:x allows you to configure nan Disk Cleanup tool’s settings. When executed, it will motorboat nan Disk Cleanup instrumentality and fto you prime circumstantial items you want to delete and delegate them to nan worth x. The x value, which tin beryllium immoderate worth from 1 to 9999, is stored successful nan registry.
  • sagerun:x runs nan specified task assigned to nan x worth and cleans each nan specified files automatically.

Here’s really it works:

  1. Type nan pursuing bid successful Command Prompt and property enter: cleanmgr /sageset:1
  2. In nan supra command, switch 1 pinch immoderate number betwixt 1 and 9999. For this guide, we’ll spell pinch 1. When executed, it will unfastened nan Disk Cleanup instrumentality and show each nan junk items you tin delete.
    cmd cleanmgr sageset 1
  3. Select aliases unselect each nan items that you want to delete. For example, prime Temporary setup files, Windows Update Cleanup, Downloaded programme files, Recycle bin (be observant pinch this one), etc.
    disk cleanup prime record types
  4. After selecting nan types of files to cleanable up, click OK to prevention nan configuration.
    cleanmgr sagerun 1
  5. Now, usage nan pursuing bid to tally nan Disk Cleanup instrumentality pinch your civilization configuration: cleanmgr /sagerun:1
  6. This will motorboat nan Disk Cleanup instrumentality and commencement cleaning up nan record types specified antecedently and assigned to nan worth 1. In this instance, it will delete Temporary setup files, Windows Update Cleanup, Downloaded programme files, and Recycle bin files.

Optimize for Low Space

The lowdisk switch, arsenic nan sanction suggests, is useful if you are moving debased connected retention abstraction connected your difficult disk. When executed, it automatically checks each record categories.

The lowdisk bid is followed by nan thrust missive for nan partition to free up space. A complete bid will look thing for illustration this:

cleanmgr /lowdisk /d

When executed, Disk Cleanup will unfastened pinch each nan junk record categories selected successful nan D: drive.

To delete each junk files quickly, without nan personification prompt, usage nan pursuing bid instead:

cleanmgr /verylowdisk /d

How to Clear Temporary Files Using nan Command Prompt?

Windows creates impermanent files for momentary use. They seldom inhabit a ample abstraction connected your difficult thrust and are basal for nan soft functioning of your system. When nan task is complete, your strategy should automatically discard them from nan impermanent folders.

The Disk Cleanup instrumentality cleans impermanent files that are older than 7 days. But if you person to cleanable nan temp files frequently, you tin do it manually aliases utilizing nan Command Prompt.

The Windows Command Prompt pinch nan del bid successful progress, showing immoderate individual files that cannot beryllium deleted

To position impermanent files, participate nan pursuing bid successful Command Prompt:

%SystemRoot%\explorer.exe %temp%\

You tin delete these files manually (Ctrl + A > Delete) from nan File Explorer aliases usage nan pursuing bid to delete temp files:

del %temp%\*.* /s /q

Command Prompt will automatically skip immoderate presently utilized file, but it will delete nan rest.

How to Delete Prefetch Files Using nan Command Prompt

Prefetch files are impermanent files created erstwhile an exertion is tally connected your Windows system. These files incorporate accusation that is utilized to optimize nan execution of programs.

Like different impermanent files, nan prefetch files often don’t return up overmuch abstraction connected your difficult drive. However, if you request to delete nan prefetch files frequently, you tin usage nan Command Prompt to cleanable up these files connected your system.

To delete nan prefetch files utilizing Command Prompt:

  1. Open Command Prompt arsenic administrator.
    prefetch record files windows
  2. In nan Command Prompt window, type nan pursuing bid to position nan prefetch files: %SystemRoot%\explorer.exe C:\Windows\prefetch\
  3. It will unfastened nan prefetch files successful File Explorer and show nan prefetch files that you tin delete.
    prefetch record files windows
  4. To delete nan prefetch files, usage nan pursuing bid and deed enter: del C:\Windows\prefetch\*.*/s/q
  5. Command Prompt will show a database of each nan deleted prefetch files.

Cleaning a Hard Disk Using Diskpart

If you want to swipe cleanable an full disk, you tin usage nan diskpart utility. Diskpart is simply a Windows command-line inferior supporting complete 38 commands for different functions.

To swipe cleanable a disk, you tin usage diskpart’s cleanable command. Upon execution, it deletes each nan information and converts nan disk into unallocated space.

The Windows bid punctual moving nan DiskPart program, pinch disposable volumes listed

Exercise be aware erstwhile utilizing nan diskpart utility. Using incorrect objects tin costs you each of your data, and you whitethorn not beryllium capable to retrieve immoderate of it astatine all. Therefore, create a backup of your captious strategy data earlier utilizing nan diskpart tool.

To cleanable a disk:

  1. Type diskpart In nan Command Prompt and deed enter.
  2. Next, type list disk to position each nan installed disks connected your strategy
  3. Select nan disk you want to swipe clean. For example: Select disk 0
  4. If nan disk position shows offline, type online disk and deed enter.
  5. To swipe cleanable your disk, type nan pursuing bid and deed enter: Clean each
  6. Once completed, type exit to adjacent diskpart.

Keep Your Computer Clean From Junk Files Using Command Prompt

You tin usage nan Command Prompt to execute various precocious actions, including removing junk files from your computer. While you tin usage nan GUI-based Disk Cleanup tool, Command Prompt makes it easy to cleanable up circumstantial types of files and swipe cleanable disks.

Source Tutorials
Tutorials