Deleting windows updates Folder content

Discussion in 'Windows 10' started by Yasser Da Silva, Aug 15, 2015.

  1. Yasser Da Silva

    Yasser Da Silva MDL Senior Member

    Mar 15, 2015
    499
    2,567
    30
    #1 Yasser Da Silva, Aug 15, 2015
    Last edited: Aug 15, 2015
    is it a good idea to delete this folder content
    "%Windir%\SoftwareDistribution\Download"
    and if a did that what will happen to installed Updates !
    and to Updates History !
    (i noticed that after deleting windows update says that you never installed an update on this PC in Win 8.1)
    if a deleted the content is Windows gonna Download them again !!
     
  2. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    8,575
    15,646
    270
    Yes a good idea.
    Nothing happens to installed updates or history.
    If you delete contents in "Download" folder Windows Update system its going to do its job again.
     
  3. Yasser Da Silva

    Yasser Da Silva MDL Senior Member

    Mar 15, 2015
    499
    2,567
    30
    what do you mean with "Windows Update system its going to do its job again"
    do you mean download the updates again
    or just list them in update history !!
     
  4. ashmicro

    ashmicro MDL Junior Member

    Mar 2, 2012
    93
    8
    0
    No, it'll just get you whatever updates you don't already have, it won't duplicate things.
     
  5. Yasser Da Silva

    Yasser Da Silva MDL Senior Member

    Mar 15, 2015
    499
    2,567
    30
    Thank you for you Help
     
  6. dhjohns

    dhjohns MDL Guru

    Sep 5, 2013
    3,262
    1,731
    120
    #6 dhjohns, Aug 15, 2015
    Last edited by a moderator: Apr 20, 2017
    Here is what I do after Windows Updates. Save as command file, and run as administrator!
    Code:
    Dism.exe /online /Cleanup-Image /StartComponentCleanup
    
    pause
    
    
    cd C:\Windows\SoftwareDistribution\
    
    
    del * /S /Q
    
    
    rmdir /S /Q "C:\Windows\SoftwareDistribution\Download\"
    
    
    pause
    
    
    shutdown.exe /r /t 0
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Yasser Da Silva

    Yasser Da Silva MDL Senior Member

    Mar 15, 2015
    499
    2,567
    30
    #7 Yasser Da Silva, Aug 15, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Good it should be better like this

    Code:
    @echo off
    
    net stop wuauserv
    
    Dism.exe /online /Cleanup-Image /StartComponentCleanup
    
    cd C:\Windows\SoftwareDistribution\
    
    del * /S /Q
    
    rmdir /S /Q "C:\Windows\SoftwareDistribution\Download\"
    
    net start wuauserv
    
    pause
    
    shutdown.exe /r /t 0
    
    
     
  8. dhjohns

    dhjohns MDL Guru

    Sep 5, 2013
    3,262
    1,731
    120
    #8 dhjohns, Aug 15, 2015
    Last edited by a moderator: Apr 20, 2017
    Thank you!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Yasser Da Silva

    Yasser Da Silva MDL Senior Member

    Mar 15, 2015
    499
    2,567
    30
    #9 Yasser Da Silva, Aug 15, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)

    I just made it more Fun to use
    this script will Get the Folder Size then clean things
    then Get the Folder Size again
    and count the difference between them and show a message Box containing the files size that you cleaned

    Tip : you can remove this part of code if you don't want the first MsgBox to show up

    Code:
    echo MsgBox "You have %MB% Mb (%GB% GB) Update Junk need to be cleaned."> msgbox.vbs
    cscript msgbox.vbs
    Del msgbox.vbs
    

    Code:
    @echo off
    set Dir="%Windir%\SoftwareDistribution"
    for /f "tokens=1,3" %%a in ('dir /w /s /-c %Dir% ^| findstr "File(s)"') do set bytes=%%b
    set /a KB=(%bytes% /1024)
    set /a MB=(%KB% /1024)
    set /a GB=(%MB% /1024)
    
    echo MsgBox "You have %MB% Mb (%GB% GB) Update Junk need to be cleaned."> msgbox.vbs
    cscript msgbox.vbs
    Del msgbox.vbs
    
    net stop wuauserv
    
    Dism.exe /online /Cleanup-Image /StartComponentCleanup
    
    cd %Windir%\SoftwareDistribution\
    
    del * /S /Q
    
    rmdir /S /Q "%Windir%\SoftwareDistribution\Download\"
    
    net start wuauserv
    
    for /f "tokens=1,3" %%a in ('dir /w /s /-c %Dir% ^| findstr "File(s)"') do set bytes2=%%b
    set /a KB2=(%bytes2% /1024)
    set /a MB2=(%KB2% /1024)
    set /a GB2=(%MB2% /1024)
    
    set /a SIZEMB=%MB%-%MB2%
    set /a SIZEGB=%GB%-%GB2%
    
    cls
    echo MsgBox "You have cleaned %SIZEMB% Mb (%SIZEGB% GB)."> msgbox.vbs
    cscript msgbox.vbs
    Del msgbox.vbs
    
     
  10. EFA11

    EFA11 Avatar Guru

    Oct 7, 2010
    8,719
    6,741
    270
    #10 EFA11, Aug 15, 2015
    Last edited by a moderator: Apr 20, 2017
    nice, and removed the reboot force reboot too, :D
     
  11. AngryBird

    AngryBird MDL Novice

    Aug 16, 2012
    21
    2
    0
    is it possible then for me to save this folder somewhere else, so that next time I reinstall windows, I just put back the folder and let windows install without downloading?
     
  12. Palladin

    Palladin MDL Senior Member

    Feb 1, 2014
    476
    248
    10
    #13 Palladin, Aug 16, 2015
    Last edited by a moderator: Apr 20, 2017
    Just one nit to pick in an otherwise great script.

    You need to run this script from your system drive, usually C:\ or you can add the system variable %systemdrive% to the very beginning of the script. If you run it from another partition, the "del * /S /Q" and subsequent commands will fail, because they are run from the current directory (D:\Software) where the script resides.

    Well they don't exactly fail, but they *will* delete all the files in the current directory including the script itself. :confused:

    Once that one change gets made the script runs perfectly and I was able to delete over 900MB of junk files.
     
  13. dhjohns

    dhjohns MDL Guru

    Sep 5, 2013
    3,262
    1,731
    120
    It did not do that for me!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. Yasser Da Silva

    Yasser Da Silva MDL Senior Member

    Mar 15, 2015
    499
    2,567
    30
    1.MSOCache
    I think this is where Office cache it files and you can update it normally if you deleted the folder
    look for it in Technet forumbut i will remove it from the script anyway

    1.SoftwareDistribution
    in this folder there is all windows update stuff
    Downloads-Logs-History...
    deleting all these files is just fine (i tried it)

    Thanks.


     
  15. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,219
    84,893
    340
    Deleting \SoftwareDistribution\DataStore\DataStore.edb is not fine at all
     
  16. Yasser Da Silva

    Yasser Da Silva MDL Senior Member

    Mar 15, 2015
    499
    2,567
    30

    :g:
    Thanks for this info
    i changed the script to this

    DEL /S /Q "%Windir%\SoftwareDistribution\Download\*.*"
     
  17. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    When using Windows 7, if I deleted all contents of the SoftwareDistribution folder, I would get errors and not be able to install some of the Microsoft Visual C++ components. Confirmed this a few times so now I learned my lesson never to touch that folder. I only use the Disk Cleanup Tool in Windows to clean the updates although it doesn't clean that folder. CCleaner doesn't clean it either so there must be a reason behind it.

    Leave the freakin's OS files alone if you don't want headaches.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...