In this chapter, you’ll discover several tools which can help you optimize your computer. You’ll learn how to manage hard drives, clean them up and automate tasks using the command line and the Task Scheduler.
Manage Your Hard Drives
The hard drive is a high-risk component of your computer.
A high-risk component? What does that mean?
Hard drives are high-risk because they are constantly being used. This constant use makes them vulnerable to certain faults, whether from the corruption of a file or hardware faults that make the hard drive unusable.
You will often need to replace hard drives, clean them up when they contain too many unused files (such as those in your Downloads folder, the recycle bin, etc.), add extra hard drives when more space is needed, or format them when the system files are corrupted and the only solution is to reinstall Windows 10.
Disk Manager
“Disk Manager” is a Microsoft tool that allows you to format a hard drive. This tool will come in useful when:
Adding a new hard drive, as it will need to be formatted to be compatible with Windows.
Partitioning a hard drive, to divide one physical hard drive into several logical partitions.
When reinstalling Windows this tool will be presented slightly differently but the steps remain the same. It will allow you to format your hard drives when installing Windows.
List your partitions
To open the Disk Manager, right-click on the Windows Start menu and click on “Disk Management”:
In the bottom section, you can see the physical hard drives (in my case I have two hard drives: Disk 0 and Disk 1) followed by each drive's partitions to the right – i.e., the logical divisions of disk 0. You can see that disks are assigned numbers, while logical partitions are assigned letters.
In the top section, you can see all the logical partitions followed by their specific details (if an operating system is installed on them, their capacity and free space, etc.).
Shrink a partition
In our case, you can see three logical partitions:
Partition C, which is the main partition and has Windows installed on it.
An EFI system partition(Extensible Firmware Interface) for starting up Windows (often used when you have several operating systems on your computer).
An OEM partition (Original Equipment Manufacturer) used by the computer’s manufacturer to store firmware and the drivers of installed equipment.
You’re now going to shrink the main partition, C, in order to add a second partition, and then separate Windows from user data (files).
But why?
If Windows becomes corrupted, you will have to reinstall it. This way, you won’t lose user data when reinstalling Windows. Otherwise, you’d have to format the entire drive and lose all of your data.
Here’s how to create a new partition from partition C:
Right-click on the partition.
Click on “Shrink Volume”.
Choose the number of megabytes by which you want to shrink C to create a new size for the partition.
Click “Shrink”.
A section marked “Unallocated” will appear.
Create a partition
Now all you need to do is format it and assign it a letter to make the partition ready to use:
Right-click on the unallocated partition and click on “New simple volume”, then:
Click “Next”.
Choose the size of the new space to be created (the maximum size is selected by default).
Click “Next”.
Assign it a letter.
Click “Next”.
Select “Format this volume with the following settings” and leave the default settings. By default, Microsoft will format the volume in NTFS (New Technology File System), which is the file system used by Windows. Other file systems cannot be read by Windows.
Give it a name.
Click “Next”.
Mission accomplished: your new volume is created and ready to use! Check the video below to see how I ran through the task before moving on:
Now let’s look at how to clean up these drives, i.e., how to delete unused files stored over time by the operating system and the user, such as those in the “Downloads” folder and recycling bin, as well as temporary files.
Clean Up Your Hard Drive
Your computer needs cleaning from time to time, just like a house does. The user must tidy files away into the right folders, just like putting things away in a cupboard, and delete anything left hanging around, like throwing out the trash.
Once again Windows has the right tool for the job. It’s called “Disk Cleanup” and you can find it in Administrative Tools.
Disk cleanup
Using this tool is very simple: just select the files to delete and click “OK”.
Let’s go one better and optimize the cleanup procedure by automating this task, to ensure your company’s users always have a clean computer.
Automate a Task
To automate tasks, Windows has a tool called “Task Scheduler”. You can find this in Administrative Tools. Open it and take a look.
With the “Task Scheduler,” you can set a program to launch with a certain frequency. You can set it to launch every Monday, for example.
To launch a program using the Task Scheduler, you need to know its file path, up until now you have been using the graphical interface without knowing the application’s file path. To do this, we’ll need to use the command line.
Use the command line to launch your app
Automating a task in Windows involves three steps:
Locate the command which corresponds to the disk cleanup tool.
Save the full command in a file with the extension “.bat”. This is the format for executing DOS commands.
Program the Task Scheduler to launch the “.bat” file on the date and time required.
Here’s how to use this command:
Open command prompt by typing “CMD” into the search bar.
Enter the command cleanmgr /c /sageset:1. cleanmgr is the disk cleanup tool, /c allows you to specify the disk (you can also choose another disk), /sageset:1 opens disk cleanup so that you can select the files you want to clean up. It creates a registry entry to store the configuration using the number entered at this point (you can use any number)
Hit enter after the command cleanmgr /c /sagerun:1. /sagerun:1 will now launch disk cleanup with the settings specified corresponding to number 1, i.e., what you entered above.
Create an executable file
To create an executable batch file with the extension “.bat”, go to a folder of your choice, create a new text document, and change the “.txt” extension to “.bat”. Windows will show a warning message explaining that your file could become unreadable.
This file is where you’ll write your executable command. A batch file is an executable that carries out the commands listed in the file in the order they are written.
Right-click on the file.
Click on “Edit”.
Insert the command: cleanmgr /c /sagerun:1.
Save and close.
You can check that disk cleanup launches by double-clicking on it.
Now, you’ll need to configure the command to run using Task Scheduler.
Schedule disk cleanup
To create a task:
Click on “Task Scheduler Library”.
In the top part of the central section, right-click and select “Create a Basic Task”.
Set a name and description for your task.
Choose a frequency. I’ve chosen daily, at 15:10.
Choose the program to launch with the scheduler.
Your task is now ready. You can test it by right-clicking on it and selecting Run to execute it.
It will start to execute by itself at 15:10 every day.
Take a look at the video below to see how I create a scheduled task in Windows.
Your Turn!
🎯 Today's mission at CleanFuture: CleanFuture’s accounting application is used to run a weekly financial report at 5:00 PM every Friday evening. The report is detailed and can be up to 300MB in size! It is critical that the report is saved every week.
To make sure there is enough space on the computer, you decide to run a regular disk cleanup on the drive. This will remove any unnecessary documents and make sure only important files are saved on the computer.
⚙️ The actions you need to take:
Create a task scheduled for every Thursday afternoon at 4:00 PM to run a disk cleanup.
✅ Double-check your work: You’ll know you’ve succeeded when Task Scheduler contains your newly created task item with the correct name, time, and date.
Let's Recap!
You’ll often need to change, remove, or add hard drives throughout your IT career.
Disk Manager is the tool that allows you to make changes to hard drives. To open it, right-click on the Windows Start menu and click on “Disk Management”.
Hard drives are assigned a number, while logical partitions are assigned a letter.
A partition is a segment of a physical hard drive.
When adding a partition, you must format it in NTFS when using Windows.
Isolating Windows to one partition is the best practice and will save you from losing all your data if you need to reinstall Windows.
You can remove unnecessary files from your computer by using Disk Cleanup.
A .bat file can be created to run executable scripts.
Task Scheduler allows you to run programs and scripts at scheduled times and dates.
This chapter is our most detailed one so far - well done for completing it! You should now have a good understanding of how to optimize and partition your hard drives. In the next chapter, we will move on to something just as important to understand for an IT technician - how to manage user accounts.