Introduction: How to Make a Command Prompt Defragmenter in Windows!! (works for All Versions of Windows)

Picture of How to Make a Command Prompt Defragmenter in Windows!! (works for All Versions of Windows)

Welcome to my first instructable! :D

Hi, my name is Kwesi Quincy (instructables username iCoder), and I am a boy of age 15 who likes to code, build stuff, and DJ. I will be posting more instructables in the future, so please stay tuned!

DISCLAIMER: I am not responsible for any bricked PCs whatsoever. USE THE CMD TOOL AT YOUR OWN RISK OR IF YOU KNOW WHAT YOU ARE DOING! DO NOT RUN ANY COMMANDS YOU DO NOT KNOW ABOUT!!


So what is a defragger? A defragger is a tool built into Windows to remove fragment of files left on your system. Basically as you remove programs from your system, there are fragments it leaves behind and eventually it accumulates and scatters in your system, so when your PC is starting up from sleep or Power On, the hard drive read head has to go on a scanning rampage to bring all files together, and in this case (if you have a HDD LED on your PC/Laptop), you will see it light up steady (not flashing) and your PC will be remarkably slow. Alternatively, you can go to Start>Type in defrag>defrag and use it, but instead of having to go through that step, you can just have a double-click shortcut on your desktop that you can access at any time just in case your HDD LED is stabily lighted, or when your PC is being slow at reading/writing files on or off the HDD. So in that case, welcome to the instructable on how to do so!! Enjoy!

Step 1: Open Notepad

Picture of Open Notepad

There are many ways to open notepad. You can use the Windows Key+R and type in Notepad or go to Start>type in notepad if it is not pinned in start menu>click notepad.

Step 2: First Steps on the Defragger

Picture of First Steps on the Defragger

For the lazy people who do not want to type everything, I included the .bat file. Feel free to download it!

Now type in:

@echo off (it turns off the C:\Users\PCNAME\ thing that shows up in CMD when you open it)

cls (clears the screen)

Step 3: Second Steps on Defragger: the Timer

Picture of Second Steps on Defragger: the Timer

This step is optional, but if you want to add a timer, you can go ahead and do so.

Use this command as many times as you want since one syntax equals one second.

ping 2 127.0.0.1>nul

Step 4: Third Steps on the Defragger: THE MAIN COMMAND

Picture of Third Steps on the Defragger: THE MAIN COMMAND

Now this is the command that does it all: the defrag command.

At this stage, type in this command:

defrag

Example: defrag /c /h /u

You can also add other stuff to the file at this point. You can ALSO make changes even after you have saved the file.

Step 5: Fourth Steps on Defragger: Saving (very Important)

Picture of Fourth Steps on Defragger: Saving (very Important)

Now here comes the important part: the saving part.

You do not want to save it as a .txt file, or it will open in notepad again.

So go to File>Save As...>and type in the name you want with the extension .bat (or it will not work)

Click on Save As type dropdown box and click All Files or it will still save as YOURNAMEHERE.bat.txt

Step 6: Creating Your Shortcut

Picture of Creating Your Shortcut

Now you want to create a shortcut in order to customize the file because the original file is not customizable (changing icons and making it run as admin - steps ahead)

So right click anywhere on the desktop and hover your cursor over New>and click shortcut

A dialog box will appear. Go to the directory you saved your file in and copy and paste it into the search bar. Then click next.

Step 7: Giving It a Name

Picture of Giving It a Name

Now give the shortcut a name (EXAMPLE: Command-line Defragger)

Click finish, and now you have the icon on your desktop.

At this point you are done! YAY. BUT ONE MORE THING BEFORE YOU OPEN IT OR IT WILL NOT WORK.

Step 8: Setting the Shortcut to Run As Administrator.

Picture of Setting the Shortcut to Run As Administrator.

You need to make sure that the shortcut is ran as administrator (which basically makes the main file run as admin, since the shortcut links to it), and in order to do it, right-click on the shortcut and click properties. Click on the Advanced button at the bottom of the Properties window. On the screen that pops up, check Run As Administrator (if you are admin it will not require the admin password, if that account has one) and click OK, then click OK on the properties box to save changes.

Step 9: Change Icon (optional)

Picture of Change Icon (optional)

This step is also optional, but you can go ahead and download icons from iconarchive.com for free if you do not want to use the built-in Windows icons.

Assuming the Properties window is still open (LOL I said close it, open it again :D) click on Change Icon, a popup will appear, just click OK or close it.

A dialog box will appear with the icons. Choose any of them or use the icon you downloaded by clicking Browse, and going to the directory in which the icon was downloaded to (e.g. C:\Users\PCNAME\Desktop) and selecting the icon. Click OK when you are done, and close the window.

REMEMBER: THIS CAN ONLY BE DONE ON THE SHORTCUT, AND NOT THE FILE ITSELF.

Step 10: Finally..... the Last Step.

Picture of Finally..... the Last Step.

Close the Properties window and open the file.

IT WORKS! YAY!

You have now made your own CMD Defragger that is easy to access! GREAT JOB!

Enjoy using the tool, and don't forget to stay tuned for more instructables!

Step 11: LOL THIS IS NOT a STEP, But My Contact Infos

Picture of LOL THIS IS NOT a STEP, But My Contact Infos

Check out my YouTube channels: https://www.youtube.com/channel/UCf3lOcvdZppa3KMOZ...

https://www.youtube.com/channel/UCJtffJzTOEHB87QJ6...

https://www.youtube.com/channel/UC5vUhAJ50XipV5zRW...

Check out my soundcloud: https://soundcloud.com/soundlogik-usa

Twitter: showofftech_ and officialsoundlogik

Instagram: officialsoundlogik and deejayawana

Facebook: https://www.facebook.com/dj.awana4

Email: frostvideosutube@gmail.com

helixfire74@gmail.com

Comments

Looken4 (author)2016-09-28

in the example;

Example: defrag /c /h /u

you never tell us what the switches do

iCoder (author)Looken42016-09-30

/h - Runs the command at normal priority

/c Performs the operation on all volumes.

/u Prints the progress of the operation on the screen.

Hope you are happy now. To learn more commands, open CMD as ADMIN (or it will not work) and type in defrag help

andrewty (author)2016-09-30

I try to download the 11steps, but the screen just refreshes and shows step 1 with the comments following on.

I tried using the "view all steps" icon but it does the same taking me straight back to showing step 1.

What's wrong?

iCoder (author)andrewty2016-09-30

It is probably a problem with the instructables page or you not have PRO. Either way I do not know what is wrong.

theformatter (author)2016-09-22

Fortunately, there's no reason to use PING as a timer any more, MS heard our complaints and in Windows 7 they finally provide us an option. For a 5 second delay use

TIMEOUT /T 5 > NUL

That actually uses the system clock to delay for an exact number of seconds rather than relying on the random amount of length that could elapse with PING

I'm glad to see that someone who is so young is interested in CMD scripts - I work with so many recent grads who can't see beyond the GUI and they have never seen the power and efficiency of CMD tools. Keep it up!

BTW: If you were trying to ping two packets with that command, it should have been

PING -n 2 127.0.0.1 > NUL

iCoder (author)theformatter2016-09-22

Also I knew the timeout was there, but I did not want it to appear there, that is why I used the ping, but I never seen the timeout command with the >nul syntaxbehind it, so thanks for telling me.

iCoder (author)iCoder2016-09-22

Timeout command*

Syntax Behind*

iCoder (author)theformatter2016-09-22

Thanks for the info! I will update it very soon!

tomatoskins (author)2016-09-21

Excellent first instructable! Can't wait till you share your other projects!

iCoder (author)tomatoskins2016-09-22

Thanks tomatoskins! I will be making more projects in the future! And BTW I am a big fan of you! :D

About This Instructable

498views

9favorites

License:

More by iCoder:How to Make a Command Prompt Defragmenter in Windows!! (works for All Versions of Windows)
Add instructable to: