Start-WindowsCleanup

Discussion in 'Scripting' started by GodHand, Sep 18, 2019.

  1. GodHand

    GodHand MDL Addicted

    Jul 15, 2016
    533
    858
    30
    Updated 02-15-2020
    - Multiple code improvements and a correction to the switch statement.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. GodHand

    GodHand MDL Addicted

    Jul 15, 2016
    533
    858
    30
    Updated 02-25-2020
    - Added parameter and switch command example details.
    - Corrected a few typos.
    - Added additional code improvements
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. GodHand

    GodHand MDL Addicted

    Jul 15, 2016
    533
    858
    30
    Updated 03-13-2020
    - Added the ability to remove all event logs and event tracer log files to the -Include parameter.
    - Changed the -Include parameter 'Restore Points' to 'RestorePoints' for convenience.
    - Additional contextual modifications.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. GodHand

    GodHand MDL Addicted

    Jul 15, 2016
    533
    858
    30
    Updated 04-19-2020
    - Added the ability to remove all outdated and duplicate device drivers selectively to the -Include parameter.
    - Additional code improvements.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Walcott

    Walcott MDL Novice

    Sep 25, 2010
    26
    9
    0
    Hi friend! Thanks for your script.
    With what extension should I save it? .cmd, .bat, .ps1?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. kaljukass

    kaljukass MDL Guru

    Nov 26, 2012
    2,313
    817
    90
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. GodHand

    GodHand MDL Addicted

    Jul 15, 2016
    533
    858
    30
    You'd save it as a .ps1 (the extension type for PowerShell script files).
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. GodHand

    GodHand MDL Addicted

    Jul 15, 2016
    533
    858
    30
    Updated 05-03-2020
    - Added a -GUI switch, that can be used in place of the -Include parameter, that outputs a Gridview GUI list of all of the values in the -Include parameter allowing for the selection of items to include in the removal process as opposed to manually entering them.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. GodHand

    GodHand MDL Addicted

    Jul 15, 2016
    533
    858
    30
    Updated 05-09-2020
    - Updated the code to include a new helper function to eliminate the redundant service and process stopping loops.
    - Included the clean-up of Microsoft Edge Chromium content in addition to the previously present Microsoft Edge HTML content.
    - The verification for the removal of downloaded content is now a messagebox utilizing Microsoft's PresentationFramework.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. safm

    safm MDL Novice

    Dec 29, 2007
    49
    4
    0
    Working great
    Thanks for this excellent job
     
  11. haz367

    haz367 MDL Member

    Jan 11, 2020
    195
    206
    10
    Indeed it is....

    [​IMG]
     
  12. zbigniew59

    zbigniew59 MDL Member

    May 14, 2016
    115
    22
    10
  13. Stafamu

    Stafamu MDL Novice

    Sep 22, 2018
    23
    7
    0
  14. zbigniew59

    zbigniew59 MDL Member

    May 14, 2016
    115
    22
    10
  15. Windows_Addict

    Windows_Addict MDL Addicted

    Jul 19, 2018
    686
    1,352
    30
    It's not working because of space in the file pathname, make sure there are no spaces in files, and path names.
     
  16. zbigniew59

    zbigniew59 MDL Member

    May 14, 2016
    115
    22
    10
  17. Windows_Addict

    Windows_Addict MDL Addicted

    Jul 19, 2018
    686
    1,352
    30
    Now you changed the .ps1 file name to clean.ps1 but you didn't change the content in the .cmd

    keep the file name as Start-WindowsCleanup.ps1 and then run .cmd file again. Verify that you have properly copied the .ps1 content from the OP.
    If still not working then zip that folder with those 2 files and share here.
     
  18. Windows_Addict

    Windows_Addict MDL Addicted

    Jul 19, 2018
    686
    1,352
    30
  19. Nikos

    Nikos MDL Novice

    Jul 20, 2010
    24
    9
    0
    @Windows_Addict I want to pass parameters to the batch script.
    Is the following script correct?
    Code:
    @echo off
    
    reg query HKU\S-1-5-19 1>nul 2>nul || (
    echo ==== Error ====
    echo Right click on this file and select 'Run as administrator'
    echo Press any key to exit...
    pause >nul
    exit /b
    )
    
    REM                                                   File name                 Function name
    powershell -ExecutionPolicy ByPass -command ". "%~dp0Start-WindowsCleanup.ps1"; Start-WindowsCleanup -Include Downloads -ComponentCleanup;"
    pause