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 Addicted

    Mar 15, 2015
    519
    2,516
    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 !!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    5,682
    13,108
    180
    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 Addicted

    Mar 15, 2015
    519
    2,516
    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 !!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. ashmicro

    ashmicro MDL Junior Member

    Mar 2, 2012
    87
    7
    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 Addicted

    Mar 15, 2015
    519
    2,516
    30
    Thank you for you Help
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. dhjohns

    dhjohns MDL Guru

    Sep 5, 2013
    2,991
    1,454
    90
    #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 Addicted

    Mar 15, 2015
    519
    2,516
    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
    
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. dhjohns

    dhjohns MDL Guru

    Sep 5, 2013
    2,991
    1,454
    90
    #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 Addicted

    Mar 15, 2015
    519
    2,516
    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
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. EFA11

    EFA11 Avatar Guru

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

    Yasser Da Silva MDL Addicted

    Mar 15, 2015
    519
    2,516
    30
    you can manage more Update and Windows 10 stuff with this script
    [h=3]http://forums.mydigitallife.net/images/icons/icon6.png Windows 10 Toggle Tweaker (V1.2) -Official thread-[/h]i added the Update cleaner to "Manage Updates" section
    I hope you like it.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. AngryBird

    AngryBird MDL Novice

    Aug 16, 2012
    20
    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?
     
  13. Palladin

    Palladin MDL Senior Member

    Feb 1, 2014
    321
    130
    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.
     
  14. dhjohns

    dhjohns MDL Guru

    Sep 5, 2013
    2,991
    1,454
    90
    It did not do that for me!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. Yasser Da Silva

    Yasser Da Silva MDL Addicted

    Mar 15, 2015
    519
    2,516
    30
    That's right
    i updated the script here
    [h=3]http://forums.mydigitallife.net/images/icons/icon6.png Windows 10 Toggle Tweaker (V1.3) -Official thread-[/h]
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. Palladin

    Palladin MDL Senior Member

    Feb 1, 2014
    321
    130
    10
    Nice fix, referencing the absolute directory.

    But I noticed you added rmdir /S /Q "%SYSTEMDRIVE%\MSOCache"

    Are you sure you want to do that? That's where all the Office stuff is kept. Without that directory you won't be able to update any of the Office components should the need arise.

    Granted it's about 800MB but it might be worth keeping around, or maybe give the option to delete it or not, with a warning of the consequences if you do.

    And I noticed that in the original script you originally deleted all the files in the SoftwareDistribution directory and then removed the directory. The updated one you just deleted all the files in all the sub-directories. I'm not sure you should delete all the files in all the sub directories. Maybe just the ones in the SoftwareDistribution\Download ?? And there's a bunch of goofy named sub-directories and sub-directories of sub-directories to deal with as well.

    Keep up the good work.
     
  17. Yasser Da Silva

    Yasser Da Silva MDL Addicted

    Mar 15, 2015
    519
    2,516
    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.


     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    7,392
    23,022
    240
    Deleting \SoftwareDistribution\DataStore\DataStore.edb is not fine at all
     
  19. Yasser Da Silva

    Yasser Da Silva MDL Addicted

    Mar 15, 2015
    519
    2,516
    30

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

    DEL /S /Q "%Windir%\SoftwareDistribution\Download\*.*"
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. Phoenix

    Phoenix MDL Expert

    May 30, 2014
    1,087
    458
    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...