Advertisement
brianfgonzalez

Windows Update Verbose CMD

Feb 17th, 2022
2,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. setlocal
  3.  
  4. if "%~1"=="" (
  5.     goto USAGE
  6. )
  7.  
  8. if "%~1"=="/?" (
  9.     goto USAGE
  10. )
  11.  
  12. REM Check for admin permission
  13. FOR /f "usebackq" %%f IN (`whoami /priv`) DO IF "%%f"=="SeTakeOwnershipPrivilege" GOTO :IS_ADMIN
  14. ECHO CreateObject("Shell.Application").ShellExecute Chr(34) ^& "%WINDIR%\System32\cmd.exe" ^& Chr(34), "/K " ^& Chr(34) ^& "%~dpfx0 %*" ^& Chr(34), "", "runas", 1 >"%TEMP%\RunAs.vbs"
  15. WScript.exe "%TEMP%\RunAs.vbs"
  16. GOTO :EOF
  17.  
  18. :IS_ADMIN
  19. set _ETLPATH=%systemdrive%\WindowsUpdateVerbose.etl
  20. set _TRACEREGKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Trace
  21. set _TRACEREGVALUE=WPPLogDisabled
  22.  
  23. REM OS Version checks
  24. for /f "skip=1 tokens=2 delims=[]" %%G in ('ver') Do (
  25.   for /f "tokens=2,3,4 delims=. " %%x in ("%%G") Do (
  26.     set _major=%%x& set _minor=%%y& set _build=%%z
  27.   )
  28. )
  29.  
  30. IF %_major% LSS 10 (
  31.     echo This script is for Windows 10 or later only.
  32.     goto :EOF
  33. )
  34.  
  35. :ARGLOOP
  36. if /I "%~1"=="/start" (
  37.     echo Starting verbose tracing for Windows Update Agent ...
  38.     goto START
  39.    
  40. ) else if /I "%~1"=="/stop" (
  41.     echo Stopping verbose tracing ...
  42.     goto STOP  
  43. )
  44.  
  45. shift
  46. goto ARGLOOP
  47.  
  48. :START
  49. @echo.
  50. reg add %_TRACEREGKEY% /v %_TRACEREGVALUE% /d 1 /t REG_DWORD /f
  51. net stop usosvc
  52. net stop wuauserv
  53. logman start WindowsUpdateLOGPS1 -ets -o %_ETLPATH% -ft 00:00:05 -nb 2 24 -bs 128 -p {0b7a6f19-47c4-454e-8c5c-e868d637e4d8} 8380415 5
  54.  
  55. @echo.
  56. echo Verbose tracing will be output to: %_ETLPATH%.
  57. echo Make sure to run %~nx0 /stop later.
  58. goto :EOF
  59.  
  60. :STOP
  61. @echo.
  62. reg delete %_TRACEREGKEY% /v %_TRACEREGVALUE% /f
  63. net stop usosvc
  64. net stop wuauserv
  65. logman stop WindowsUpdateLOGPS1 -ets
  66.  
  67. @echo.
  68. echo Done! Verbose ETL file is at %_ETLPATH%
  69.  
  70. goto :EOF
  71.  
  72. :USAGE
  73. @echo.
  74. echo %~nx0 [/start] [/stop]
  75. @echo.
  76. echo Enable verbose Windows Update Agent tracing on Windows 10.
  77. @echo.
  78. echo Options:
  79. echo    /start    Start verbose tracing.
  80. echo    /stop     Stop and flush verbose tracing.
  81. @echo.
  82. goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement