Check the state of the OS and proceed accordingly.

Page 5 of 7 FirstFirst ... 34567 LastLast
  1. Kyhi's Avatar
    Posts : 3,539
    Windows 3.1 to Windows 10
       #41

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

    Maybe you need to address your Host OS
      My Computer

  2. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #42

    The "getadmin.vbs" created by your CMD code is:
    Code:
    Set UAC = CreateObject("Shell.Application") : UAC.ShellExecute "cmd.exe", "/k cd ""E:\A folder\"" && E:\A folder\ImageHealth.cmd ", "", "runas", 1
    The above does not work at my end, while the following does:

    Code:
    Set UAC = CreateObject("Shell.Application") : UAC.ShellExecute "E:\A folder\Get admin.cmd",cmd,"","runas",1
      My Computer

  3. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #43

    @Kyhi,

    In your ImageHealth.cmd, option 3 cannot proceed if no ISO has been mounted beforehand. I just found that ISO can be mounted via a CMD command: Mount or Unmount ISO and IMG file in Windows 10

    Would you consider adding it into your script?
      My Computer

  4. rqhhe's Avatar
    Posts : 46
    win 10 pro
       #44

    Paul Black said:
    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 WinSxS folder is 6.60 GB.
    should these commands sufficient to reduce its size .
    thanks..
      My Computer

  5. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #45

    Before running Disk Cleanup, my WinSxS was 5.26 GB.
    After running Disk Cleanup, it remains 5.26 GB.
      My Computer

  6. Ztruker's Avatar
    Posts : 13,502
    Windows 10 Pro X64 20H4 19042.746
       #46

    I'm trying to use the code Matthew posted earlier but having now success. The batch file is fairly simple.

    Code:
    @Echo on
    Rem Tuneup.bat
    Rem Written by Ztruker @ tenforums.com based on a post by Zbook at tenforums.com.
    Rem Must be run from a Elevated Command Prompt or Powershell
    Rem The first 4 commands will take quite a while to run.
    
    Rem If not admin NET SESSION wil fail and call Powershell to run batch as Admin
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    
    echo. >&2
    echo The following commands will be run in sequence.
    echo The first 4 will take quite awhile to run, be patient.
    echo. >&2
    echo sfc /scannow
    echo dism /online /cleanup-image /scanhealth
    echo dism /online /cleanup-image /restorehealth
    echo sfc /scannow
    echo chkdsk /scan
    echo wmic recoveros get autoreboot
    echo wmic recoveros set autoreboot = false
    echo wmic recoveros get autoreboot
    echo wmic recoveros get DebugInfoType
    echo wmic recoveros set DebugInfoType = 7
    echo wmic recoveros get DebugInfoType
    echo bcdedit --% /enum {badmemory}
    
    @echo on
    rem sfc /scannow
    rem dism /online /cleanup-image /scanhealth
    rem dism /online /cleanup-image /restorehealth
    
    rem sfc /scannow
    
    rem chkdsk /scan
    
    wmic recoveros get autoreboot
    wmic recoveros set autoreboot = false
    wmic recoveros get autoreboot
    wmic recoveros get DebugInfoType
    wmic recoveros set DebugInfoType = 7
    wmic recoveros get DebugInfoType
    
    Rem for Powershell
    bcdedit --% /enum {badmemory}
    Rem for Command Prompt
    bcdedit /enum {badmemory}
    When I run it from a standard Command Prompt I get this:

    D:\Batch Files>Tuneup-mod.bat

    D:\Batch Files>Rem Tuneup.bat

    D:\Batch Files>Rem Written by Ztruker @ tenforums.com based on a post by Zbook at tenforums.com.

    D:\Batch Files>Rem Must be run from a Elevated Command Prompt or Powershell

    D:\Batch Files>Rem The first 4 commands will take quite a while to run.

    D:\Batch Files>Rem If not admin NET SESSION wil fail and call Powershell to run batch as Admin

    D:\Batch Files>(Net session 1>nul 2>&1 ) || (PowerShell start """Tuneup-mod.bat""" -verb RunAs & Exit /B )
    start : This command cannot be run due to the error: The system cannot find the file specified.
    At line:1 char:1
    + start "Tuneup-mod.bat" -verb RunAs
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
      My Computers

  7. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #47

    I saw your above post after replying to your private message.

    Ztruker said:
    start : This command cannot be run due to the error: The system cannot find the file specified.
    At line:1 char:1
    + start "Tuneup-mod.bat" -verb RunAs
    You may run If exist "Tuneup-mod.bat" (Echo It exists.) and see whether it exists.
    If it exists, run PowerShell start "Tuneup-mod.bat" -verb RunAs
      My Computer

  8. Ztruker's Avatar
    Posts : 13,502
    Windows 10 Pro X64 20H4 19042.746
       #48

    How could it not exist, it's currently running?

    I've also tried invoking it using the full path like so:

    from C:\Users\ztruk> I ran d:\batchfiles\tuneup-mod.bat

    It's a moot point now as I have a useable solution but I really would like to understand why it doesn't work.

    I really appreciate your help Matthew.

    I'll try what you've suggested above just to see what it shows.
      My Computers

  9. Try3's Avatar
    Posts : 7,379
    Windows 10 Home x64 Version 20H2 Build 19042.868
       #49

    Rich,

    If you open an admin prompt and change to the d:\batchfiles folder, does your [elevated] admin account have permission to list the folder contents and to run the d:\batchfiles\tuneup-mod.bat file?

    I cannot say that permissions are affecting this problem but it seems worth checking.

    Denis
      My Computer

  10. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #50

    Also try the following on standard Command Prompt:

    (Powershell "Start-Process ""d:\batchfiles\tuneup-mod.bat""")
      My Computer


 
Page 5 of 7 FirstFirst ... 34567 LastLast

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




Windows 10 Forums