Delete Log Files From Windows Directory Using Command Prompt

Many a times after using numerous tools for cleaning clutter from a system, the primary drive still seems to lack free space despite the fact that there is little data saved on it. This is because there are many log files that remain in the Windows directory in the primary drive, which many tools are unable to remove. This command line will help you remove such unnecessary files which will help clear the log files from the Windows directory.

Simply open the command prompt and type cd\ and hit enter. Then type cd windows to select the Windows directory and hit enter again. This will select the appropriate directory and give you the access from the command prompt to delete log files. Now type del *.log /a /s /q /f  and press enter to delete the log files.


All log files will be deleted from the directory. In this command “a” signifies all, whereas “s” deletes files from all sub folders, “q” bars from any prompts to ask for a yes/ no question and “f” forcibly removes the files.

Deleting Files

Being a system administrator, I have used this command line to free as much as 500mb of clutter from systems that had not be formatted for a long period of time. It is worth mentioning here that many cleaning tools had already been used on these systems on a periodic basis including the windows disk cleaner. However, these log files never seemed to be removed until this command was used.

Advertisement
  • Andre

    Actually the command is

    del *.log /a /s /q /f

    • Gregg DesElms

      Yeah. I was wondering what the “8″ was for. Andre’s right.

      Also, as nice as some people might find doing something cool from the command prompt, those of us who were around when the very first IBM PC was released to market, and so who used DOS, exclusively, for years, have long ago lost our ability to impress ourselves with command prompt tricks. We who are in that situation have noticed that CCleaner (among tons of other freeware and open source tools) will delete .LOG files, system wide, without having to know anything about the command prompt. Since most Windows users have little interest in the command prompt, they’d probably prefer using something like CCleaner, too.

      Just a thought.

      _________________________________
      Gregg L. DesElms
      Napa, California USA
      gregg at greggdeselms dot com

      • http://www.addictivetips.com/ Farshad

        Gregg, as I mentioned in the article, many cleaning tools had already been used on the systems that I referred to. Although I knew better, yet to double check I ran the cc cleaner on my PC and then used this command line. The result was that the cc cleaner had left behind many log files in the windows directory that were only removed after I ran this command. You are right about the cc cleaner deleting different kinds of log files, however, I referred to the windows directory as this command is meant to delete the log files of this directory.

  • http://www.addictivetips.com/ Farshad

    Thank you for pointing out the typo.

  • Sirot

    many installer programs use .log files to hold uninstallation info.
    some of them (unfortunately) save it in windows subdirectories.

    • http://www.addicitivetips.com Nakodari

      You are correct. This warning must be mentioned for beginners!

  • william

    When i type into command prompt del *.log /a /s /q /f the files all appear but it says below each file access denied

    • Pradeep

      Yup..i got the same message as william got..
      ACCESS DENIED 

      PS : am not d administrator. i might b logged in as guest. but still i wish to delete ma log files. u know.. Security issues :)

  • Vickrant Sawant

    There are two files for which I got Access Denied error:
    1) C:Windowswinsxspoqexec.log

    2) C:Windowswinsxsx86_microsoft-windows-com-dtc-runtime_31bf3856ad364e35_6.1.760
    0.16385_none_19295908c15690f3MSDTC.LOG

    Rest all were deleted…

  • Andrew

    I’ve used this command to free as much as 50GB from SBS servers. Very useful.