Check the state of the OS and proceed accordingly.

Page 1 of 7 123 ... LastLast

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

    Check the state of the OS and proceed accordingly.


    I am at the end of testing customisations for my Win 10 and I thought it would be a nice idea to have the health etc and repair for Win 10 in one location.

    I am intending on setting up a folder within my customised TaskBar folder with a shortcut for each item to allow me to have at hand everything needed for this to be achieved. I might even setup a .CMD file for this! This could also be adapted to include it into the Contect Menu as a single menu.

    I have tried to include below the CMD and PowerShell commands in case anyone wants the option. I have numbered these in the order that I think they are relevant. I intend to use CMD rather than PowerShell where possible as I am more comfortable with CMD.

    If there is anything wrong with any of the below, or you think the order is incorrect, or there is anything else that could be included, then please let me know.

    [01] Analyze The Windows WinSXS Component Store_Directory:
    Code:
    Dism.exe /online /Cleanup-Image /AnalyzeComponentStore

    [02] Delete WinSXS Obsolete Items:
    Code:
    Dism.exe /online /Cleanup-Image /StartComponentCleanup

    [03] Remove ALL WinSXS Superseded Component Versions:
    Code:
    Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

    [04] Remove ALL WinSXS Service Pack Backup_Files:
    Code:
    Dism.exe /online /Cleanup-Image /SPSuperseded

    [05] CheckHealth of the Win Image - Basic scan to determine if there are any corruptions - [ Live OS ]:
    Code:
    Dism /Online /Cleanup-Image /CheckHealth
    Code:
    @="PowerShell.exe -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, Dism /Online /Cleanup-Image /CheckHealth' -Verb runAs\""

    [06] ScanHealth of the Win Image - Advanced scan to determine if there are any problems - [ Live OS ]:
    Code:
    Dism /Online /Cleanup-Image /ScanHealth
    Code:
    @="PowerShell.exe -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, Dism /Online /Cleanup-Image /ScanHealth' -Verb runAs\""

    [07] RestoreHealth of the Win Image - Advanced scan that repairs any problems - [ Live OS ]:
    Code:
    Dism /Online /Cleanup-Image /RestoreHealth
    Code:
    @="PowerShell.exe -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, Dism /Online /Cleanup-Image /RestoreHealth' -Verb runAs\""

    [08] chkdsk - Read-Only Mode + Detect Mode:
    Code:
    C:\Windows\System32\cmd.exe /k chkdsk C:

    [09] chkdsk /F - Repair Mode:
    Code:
    C:\Windows\System32\cmd.exe /k chkdsk C: /F

    [10] chkdsk /R - Repair Mode + Scan for Bad Sectors:
    Code:
    C:\Windows\System32\cmd.exe /k chkdsk C: /R

    [11] Run sfc /scannow Command at Boot - Allows better repair because files are NOT in use - [ Offline OS ]:
    Code:
    [sfc /scannow /offbootdir=<drive Path>:\ /offwindir=<drive Path>:\Windows

    [12] Run sfc /scannow from within Windows - Repair files - [ Live OS ]:
    Code:
    @="PowerShell.exe -windowstyle hidden -command \"Start-Process cmd -ArgumentList '/s,/k, sfc /scannow' -Verb runAs\""

    [13] SFC Scan Details Log - View Only the SFC Scan ERROR Results from the CBS.LOG [ Live OS ]:
    Code:
    FindSTR /c:"[SR]" %windir%\Logs\CBS\CBS.log >"%UserProfile%\Desktop\sfc_Details.txt"
    Code:
    @="PowerShell.exe (sls [SR] $env:windir\\Logs\\CBS\\CBS.log -s).Line >\"$env:UserProfile\\Desktop\\sfc_Details.txt\""

    Thanks in advance.
      My Computer


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

    Paul Black said:
    I might even setup a .CMD file for this!
    Something like this? The list can include all the 13 options in your post.
      My Computer


  3. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #3

    I have created the below menu [ no code as yet ].
    I have tried to include what I think are the main options for a clean and healthly OS! . . .

    Check the state of the OS and proceed accordingly.-menu.jpg

    I will probably start on the code later this week!
    Last edited by Paul Black; 19 May 2020 at 09:04.
      My Computer


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

    I am looking forward to the release of your breathtaking codes!
      My Computer


  5. Posts : 5,048
    Windows 10/11 Pro x64, Various Linux Builds, Networking, Storage, Cybersecurity Specialty.
       #5

    Matthew Wai said:
    I am looking forward to the release of your breathtaking codes!
    I agree. Count me in. Maybe you can sell the source to Microsoft!

      My Computer


  6. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #6

    Would anyone who has recently run Dism.exe /Online /Cleanup-Image /ScanHealth and Dism.exe /Online /Cleanup-Image /RestoreHealth [ using WU for the repair option as opposed to a mounted install.wim ] be prepared to upload / post the C:\Windows\Logs\DISM\dism.log please?

    Upload => How to Upload and Post Screenshots and Files at Ten Forums.

    The dism.log will only be of use if the above has been run!

    I have not got access to a Win 10 computer at the moment and I would like to run some tests on the information in a dism.log file for this program that I am writing.

    Thanks in advance.
    Last edited by Paul Black; 19 May 2020 at 08:11.
      My Computer


  7. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #7

    UPDATE:

    I have managed to get hold of a dism.log AFTER the running of Dism.exe /Online /Cleanup-Image /ScanHealth.

    If anyone has got the dism.log AFTER running Dism.exe /Online /Cleanup-Image /RestoreHealth and would be kind enough to upload it please, I would be grateful!
      My Computer


  8. Posts : 4,144
    Windows 3.1 to Windows 11
       #8

    or something like this
    Check the state of the OS and proceed accordingly.-image048.jpg
      My Computer


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

    Anyone want to have a play with this first version?

    Download => Attachment 279387.

    I suggest advanced users only at the present time!
    Last edited by Paul Black; 19 May 2020 at 13:09.
      My Computer


  10. Posts : 4,144
    Windows 3.1 to Windows 11
       #10

    to help you with "Run As Admin"
    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 ============================================================
    echo ERROR: Run the script as administrator.
    echo ============================================================
    echo.
    echo Press any key to exit...
    pause >nul
    goto :eof
    )
      My Computer


 

  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 11:31.
Find Us




Windows 10 Forums