Clear Windows Update History in Windows 10  

Page 6 of 7 FirstFirst ... 4567 LastLast

  1. DMD
    Posts : 86
    W10 Pro 64 bit 21H1
       #50

    @Paul Black
    Thank you very much
      My Computer


  2. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #51

    DMD said:
    @Paul Black
    Thank you very much
      My Computer


  3. Posts : 7,607
    Windows 10 Home 20H2
       #52

    Paul Black said:
    Code:
    set "params=%*"
    setlocal EnableDelayedExpansion
    cd /d "%~dp0" && (if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs") && fsutil dirty query %systemdrive% 1>nul 2>nul || (echo set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /b)
    %windir%\system32\reg.exe query "HKU\S-1-5-19" 1>nul 2>nul || (
    echo. & echo  This program MUST be run as an Administrator. & echo. & echo  Right-click the batch file and click Run as administrator. & echo. & echo ^>Press ANY key to EXIT . . . & pause >nul & goto :End
    )
    cls

    It will run the batch script as Administrator!
    The one below is much simpler:

    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)

    The script will be run with administrative privileges. RunAs = "Run as administrator".
      My Computer


  4. DMD
    Posts : 86
    W10 Pro 64 bit 21H1
       #53

    Matthew Wai said:
    The one below is much simpler:

    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)

    The script will be run with administrative privileges. RunAs = "Run as administrator".
    Another alternative that I didn't know.
    Thanks
      My Computer


  5. Posts : 7,607
    Windows 10 Home 20H2
       #54

    @DMD, I just looked at the first part of your code. The following (simplified version) is my suggestion:
    Code:
    @echo off
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    Color 2f
    :: ---------------- Detect Windows version ----------------------
    For /f "tokens=2 delims==" %%# in ('"wmic path Win32_OperatingSystem get Version /value"') Do (
    Set Build=%%#)
    echo ================================================
    echo.
    echo   Clear Windows Update history
    echo         for Windows %Build%
    echo   Restore Windows Update Components
    echo.
    echo ================================================
    echo.
    echo.
    echo  Do you want to start? (Y/N):
    CHOICE /C "YN" /M "Your choice?:" >nul 2>&1
    if %errorlevel%==2 (Exit) 
    
    :avvio
    cls
    :: ---------------- Decision dependent on the version of Windows ----------------------
    Just double-click to run it. When it asks "Do you want to start? (Y/N):", press a key that is NOT (Y/N), and you will hear a beep.
    I will look at the rest tomorrow.
      My Computer


  6. DMD
    Posts : 86
    W10 Pro 64 bit 21H1
       #55

    @Matthew Wai
    Thanks for your interest.
      My Computer


  7. Posts : 7,607
    Windows 10 Home 20H2
       #56

    DMD said:
    Code:
    :: Prompt to Run as administrator
    Set "Variable=0" & if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
    fsutil dirty query %systemdrive%  >nul 2>&1 && goto :(Privileges_got)
    If "%1"=="%Variable%" (echo. &echo. Please right-click on the file and select &echo. "Run as administrator". &echo. Press any key to exit. &pause>nul 2>&1& exit)
    cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%Variable%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs" & exit
    :(Privileges_got)
    The above code was added by Brink at my suggestion: Reset Windows Update in Windows 10
    However, this code is redundant and can be deleted if you use my suggestion in post #54 above.
      My Computer


  8. Posts : 4
    Windows 10
       #57

    PowerShell version (self-elevating)


    Code:
    if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::
        GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
        Start-Process PowerShell "-File ""$PSCommandPath""" -Verb RunAs
        exit
    }
    
    Stop-Service "UsoSvc","wuauserv" -PassThru
    
    Remove-Item "C:\Windows\SoftwareDistribution\DataStore\Logs\edb.log"
    Remove-Item "C:\ProgramData\USOPrivate\UpdateStore\*.*"
    
    if ($Error.Count -eq 0) { Write-Host "`n`nSUCCESS: Windows Update History was cleared.`n" }
    
    Start-Service "UsoSvc","wuauserv" -PassThru | Out-Host
    UsoClient.exe RefreshSettings
    
    pause
    PassThru option, Write-Host Success message and pause are optional.
      My Computer


  9. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #58

    Hello @Matthew Wai,

    A couple of quick questions please.

    I use your Script to control WU's.

    However, I have .etl files in BOTH of the following folders . . .

    C:\ProgramData\USOShared\Logs\System
    C:\ProgramData\USOShared\Logs\User

    • If I was to run EITHER of the Scripts in Post #1 [ attached below ], would that interfere with your Script to control WU's as it uses net start wuauserv?

    Code:
    
    PowerShell -WindowStyle Hidden -Command "Start-Process cmd -ArgumentList '/s, /c, net stop wuauserv & del %SystemRoot%\SoftwareDistribution\DataStore\Logs\edb.log & net start wuauserv' -Verb RunAs"
    Code:
    
    PowerShell -WindowStyle Hidden -Command "Start-Process cmd -ArgumentList '/s, /c, net stop usosvc & net stop wuauserv & del %SystemRoot%\SoftwareDistribution\DataStore\Logs\edb.log & del /f /q C:\ProgramData\USOPrivate\UpdateStore\* & net start usosvc & net start wuauserv & UsoClient.exe RefreshSettings' -Verb RunAs"
    
    

    • To your knowledge, can ALL the files in the TWO USOShared\Logs folders be SAFELY Deleted?

    Thank you.
      My Computer


  10. Posts : 7,607
    Windows 10 Home 20H2
       #59

    Paul Black said:
    If I was to run EITHER of the Scripts in Post #1 [ attached below ], would that interfere with your Script to control WU's as it uses net start wuauserv?
    No interference. None of my scripts touches "wuauserv", which has never been disabled on my Windows 10. In fact, "Check_for_updates.vbs" and "WDD_Updates.vbs" use "wuauserv" every day.

    Paul Black said:
    I have .etl files in BOTH of the following folders . . .
    So do I. The files do not seem to have interfered with my scripts.

    Paul Black said:
    To your knowledge, can ALL the files in the TWO USOShared\Logs folders be SAFELY Deleted?
    I am not knowledgeable enough to answer the question. I have never touched the files.
      My Computer


 

Tutorial Categories

Clear Windows Update History in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 14:30.
Find Us




Windows 10 Forums