Slimdown10 – turn Windows 10 22H2 or LTSC 2021 into classic/legacy Windows

Discussion in 'Windows 10' started by Deleted member 190847, Feb 15, 2023.

  1. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    #2481 sainfo, Mar 23, 2025
    Last edited: Mar 23, 2025
    Needless to say, the Win11LiteCreator tool is also a pretty interesting solution for cleaning up an image from “junk”. But unless you are a PowerShell expert, you are unlikely to be able to change anything to suit your preferences in this script.

    SunLion's script is not simple either, but it uses dism, which allows a user who is not very knowledgeable in programming to easily edit this script to suit their needs. In general, as they say, to each his own, who likes what. But personally I would prefer the script from SunLion, where the script code is clear to the user and quite easy to edit to your preferences, as for me - a very good script!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    #2482 sainfo, Mar 23, 2025
    Last edited: Mar 23, 2025
    Hi, can you see what the reason is?

    1. When executing this code, it gives an error:

    !RemoveUWPapp!
    """" is not an internal or external command, essotable program or batch fillet.
    Code:
    echo.
    ECHO.
    ECHO ============================================================
    ECHO Remove Provisioned AppxPackages
    ECHO ============================================================
    for /f "tokens=2 delims=: " %%a in ('start "" /b "%DISM%" /English /Image:"%~dp0mount" /Get-ProvisionedAppxPackages ^| find "PackageName"') do (
    Set "RemoveUWPapp=%%a"
    
    for %%u in (
    DesktopAppInstaller
    SecHealthUI
    ) do (
      ECHO %%a | findstr /l /i /c:"%%u" >nul 2>&1 && set RemoveUWPapp=
    )
    
    If not "!RemoveUWPapp!"=="" (
      ECHO !RemoveUWPapp!
     "%DISM11%" /english /quiet /Image:"%~dp0mount" /Remove-ProvisionedAppxPackage /PackageName:"!RemoveUWPapp!"
      )
    )
    
    

    2. When executing this code, it gives an error:

    """" is not an internal or external command, essotable program or batch fillet
    Code:
    ECHO.
    ECHO ====================================
    ECHO Cleanup spsuperseded of install.wim
    ECHO ====================================
    "%DISM11%" /English /Image:"%~dp0mount" /Cleanup-Image /spsuperseded
    
    

    3. When executing this code, an error is generated and the Remove-Edge command is not executed:
    Code:
    echo.
    echo.
    echo ============================================================
    echo Remove-Edge
    echo ============================================================
    "%DISM11%" /English /image:"%~dp0mount" /Remove-Edge
    
    
    But if you write the code like this, the Remove-Edge command will run normally.
    Code:
    echo.
    echo.
    echo ============================================================
    echo Remove-Edge
    echo ============================================================
    Dism /Image:"%~dp0mount" /Remove-Edge
    
    
    Otherwise everything is fine, no errors.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. wuliyen

    wuliyen MDL Novice

    Oct 6, 2009
    34
    55
    0
    try
    %DISM11% /scratchdir:temp /image:mount /Remove-Edge
     
  4. Low Level Perform

    Low Level Perform MDL Junior Member

    Jul 21, 2024
    83
    83
    0
    Will this command also remove edge webview2?
    I was hoping for a command that would only remove the edge browser, leaving edge webview2.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. wuliyen

    wuliyen MDL Novice

    Oct 6, 2009
    34
    55
    0
    \Windows\System32\Microsoft-Edge-WebView will be retained,
    but some software will only recognize this path: \Program Files (x86)\Microsoft\EdgeWebView

    You can just delete it like this
    rd /s /q "mount\Program Files (x86)\Microsoft\Edge"
    rd /s /q "mount\Program Files (x86)\Microsoft\EdgeCore"
    rd /s /q "mount\Program Files (x86)\Microsoft\EdgeUpdate"
     
  6. SunLion

    SunLion MDL Addicted

    May 11, 2011
    952
    2,873
    30

    Did you change anything in the DISM definition?
    This seems to be happening because of the Host OS and the configured DISM...

    Your Host OS is Windows 11, correct?

    Try changing in command from %DISM11% to %DISM10% and see if everything works...

    I'll test it on the Windows 11 Host OS to see what happens.
     
  7. SunLion

    SunLion MDL Addicted

    May 11, 2011
    952
    2,873
    30
  8. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    #2488 sainfo, Mar 23, 2025
    Last edited: Mar 23, 2025
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. SunLion

    SunLion MDL Addicted

    May 11, 2011
    952
    2,873
    30
  10. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    #2490 sainfo, Mar 23, 2025
    Last edited: Mar 23, 2025
    Used version 10, Slim parameter. Well, I'll try to figure out this situation.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. SunLion

    SunLion MDL Addicted

    May 11, 2011
    952
    2,873
    30
    In the first test I ran 24H2_Integrator_10.0_Start.cmd.

    I ran another test, this time I ran Start10.0.cmd.

    Same result, no errors.

    I don't know what's going on there...

    You could try @wuliyen's suggestion above.
     
  12. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    #2492 sainfo, Mar 23, 2025
    Last edited: Mar 23, 2025
    Got it, thanks, I'll try to experiment with this option Removes Appx Packages and Appx Provisioned Packages for All Users:
    Code:
    DISM.exe /Image:<path_to_image_directory> [/Get-ProvisionedAppxPackages | /Add-ProvisionedAppxPackage | /Remove-ProvisionedAppxPackage | /Set-ProvisionedAppxDataFile | /StubPackageOption]
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. SunLion

    SunLion MDL Addicted

    May 11, 2011
    952
    2,873
    30
    Please try changing the line below and test it:

     
  14. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    Thank you very much, I will definitely test this version of your code.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. ahczwudichao

    ahczwudichao MDL Junior Member

    May 1, 2013
    96
    82
    0
    hi @wuliyen, does this ps1 script does the job or could you share yours please ?

    Code:
    # Define a function to convert wildcard patterns to regex
    function Convert-WildcardToRegex {
        param($pattern)
        $regex = [regex]::Escape($pattern) -replace '\\\*', '.*'
        return $regex
    }
    
    # Define paths
    $sourceDirectory = "C:\TEMP\scratchdir\Windows\WinSxS"
    $destinationDirectory = "C:\TEMP\scratchdir\Windows\WinSxS_edit"
    $manifestSource = Join-Path -Path $sourceDirectory -ChildPath "Manifests"
    $manifestDest = Join-Path -Path $destinationDirectory -ChildPath "Manifests"
    
    # Define the list of directory patterns to retain in WinSxS
    $dirsToCopy = @(
        "amd64_microsoft-windows-deployment_*",
        "amd64_microsoft-windows-g..ntservice.resources_*_zh-cn_*",
        "amd64_microsoft-windows-international-core_*",
        "amd64_microsoft-windows-p..ing-lpdprintservice_*",
        "amd64_microsoft-windows-p..ntservice.resources_*_zh-cn_*",
        "amd64_microsoft-windows-p..rtmonitor.resources_*_zh-cn_*",
        "amd64_microsoft-windows-p..ting-lprportmonitor_*",
        "amd64_microsoft-windows-printing-powershell_*",
        "amd64_microsoft-windows-security-spp-ux_*",
        "amd64_microsoft-windows-servicingstack_*",
        "amd64_microsoft-windows-shell-setup_*",
        "amd64_microsoft-windows-tapicore.resources_*_zh-cn_*",
        "amd64_microsoft-windows-tapicore_*",
        "amd64_microsoft-windows-unattendedjoin_*",
        "amd64_microsoft-windows-userdeviceregistration_*",
        "amd64_microsoft.vc80.*",
        "amd64_microsoft.vc90.*",
        "amd64_microsoft.windows.c..-controls.resources_*_5.82.*_zh-cn_*",
        "amd64_microsoft.windows.c..-controls.resources_*_6.0.*_zh-cn_*",
        "amd64_microsoft.windows.common-controls_*_5.82.*",
        "amd64_microsoft.windows.common-controls_*_6.0.*",
        "amd64_microsoft.windows.gdiplus_*",
        "amd64_microsoft.windows.i..utomation.proxystub_*",
        "amd64_microsoft.windows.isolationautomation_*",
        "wow64_microsoft-windows-printing-powershell_*",
        "wow64_microsoft-windows-tapicore.resources_*_zh-cn_*",
        "wow64_microsoft-windows-tapicore_*",
        "x86_microsoft.vc80.*",
        "x86_microsoft.vc90.*",
        "x86_microsoft.windows.c..-controls.resources_*_5.82.*_zh-cn_*",
        "x86_microsoft.windows.c..-controls.resources_*_6.0.*_zh-cn_*",
        "x86_microsoft.windows.common-controls_*_5.82.*",
        "x86_microsoft.windows.common-controls_*_6.0.*",
        "x86_microsoft.windows.gdiplus_*",
        "x86_microsoft.windows.i..utomation.proxystub_*",
        "x86_microsoft.windows.isolationautomation_*"
    )
    
    # Define the list of file patterns to retain in WinSxS\Manifests
    $filesToCopy = @(
        "amd64_microsoft-windows-com-dtc-runtime_*",
        "amd64_microsoft-windows-coreos-revision_*",
        "amd64_microsoft-windows-deployment_*",
        "amd64_microsoft-windows-enhancedstorage-adm_*",
        "amd64_microsoft-windows-explorer_*",
        "amd64_microsoft-windows-g..ntservice.resources_*",
        "amd64_microsoft-windows-i..national-core-winpe_*",
        "amd64_microsoft-windows-international-core_*",
        "amd64_microsoft-windows-p..ing-lpdprintservice_*",
        "amd64_microsoft-windows-p..ntservice.resources_*",
        "amd64_microsoft-windows-p..rtmonitor.resources_*",
        "amd64_microsoft-windows-p..ting-lprportmonitor_*",
        "amd64_microsoft-windows-printing-powershell_*",
        "amd64_microsoft-windows-r..-service.deployment_*",
        "amd64_microsoft-windows-security-spp-ux_*",
        "amd64_microsoft-windows-servicingstack_*",
        "amd64_microsoft-windows-setup_*",
        "amd64_microsoft-windows-shell-setup_*",
        "amd64_microsoft-windows-unattendedjoin_*",
        "amd64_microsoft.vc80.*",
        "amd64_microsoft.vc90.*",
        "amd64_microsoft.windows.c..-controls.resources_*_5.82.*_zh-cn_*",
        "amd64_microsoft.windows.c..-controls.resources_*_6.0.*_zh-cn_*",
        "amd64_microsoft.windows.common-controls_*_5.82.*",
        "amd64_microsoft.windows.common-controls_*_6.0.*",
        "amd64_microsoft.windows.gdiplus_*_1.0.*",
        "amd64_microsoft.windows.gdiplus_*_1.1.*",
        "amd64_microsoft.windows.i..utomation.proxystub_*",
        "amd64_microsoft.windows.isolationautomation_*",
        "amd64_microsoft.windows.systemcompatible_*",
        "amd64_policy.8.0.microsoft.vc80.*",
        "amd64_policy.9.0.microsoft.vc90.*",
        "wow64_microsoft-windows-printing-powershell_*",
        "wow64_microsoft.windows.gdiplus.systemcopy_*",
        "x86_microsoft.vc80.*",
        "x86_microsoft.vc90.*",
        "x86_microsoft.windows.c..-controls.resources_*_5.82.*_zh-cn_*",
        "x86_microsoft.windows.c..-controls.resources_*_6.0.*_zh-cn_*",
        "x86_microsoft.windows.common-controls_*_5.82.*",
        "x86_microsoft.windows.common-controls_*_6.0.*",
        "x86_microsoft.windows.gdiplus_*_1.0.*",
        "x86_microsoft.windows.gdiplus_*_1.1.*",
        "x86_microsoft.windows.i..utomation.proxystub_*",
        "x86_microsoft.windows.isolationautomation_*",
        "x86_microsoft.windows.systemcompatible_*",
        "x86_policy.8.0.microsoft.vc80.*",
        "x86_policy.9.0.microsoft.vc90.*"
    )
    
    # Convert patterns to regex for efficient matching
    $dirRegex = ($dirsToCopy | ForEach-Object { Convert-WildcardToRegex $_ }) -join "|"
    $fileRegex = ($filesToCopy | ForEach-Object { Convert-WildcardToRegex $_ }) -join "|"
    
    # Create the destination directory
    New-Item -Path $destinationDirectory -ItemType Directory -Force
    
    # Copy retained directories from WinSxS
    $sourceDirs = Get-ChildItem -Path $sourceDirectory -Directory | Where-Object { $_.Name -match $dirRegex }
    foreach ($sourceDir in $sourceDirs) {
        $destDir = Join-Path -Path $destinationDirectory -ChildPath $sourceDir.Name
        Write-Host "Copying $($sourceDir.FullName) to $destDir"
        Copy-Item -Path $sourceDir.FullName -Destination $destDir -Recurse -Force
    }
    
    # Create Manifests directory in the destination and copy retained files
    New-Item -Path $manifestDest -ItemType Directory -Force
    $manifestFiles = Get-ChildItem -Path $manifestSource -File | Where-Object { $_.Name -match $fileRegex }
    foreach ($file in $manifestFiles) {
        Write-Host "Copying $($file.FullName) to $manifestDest"
        Copy-Item -Path $file.FullName -Destination $manifestDest -Force
    }
    
    # Delete the original WinSxS folder
    Write-Host "Deleting WinSxS. This may take a while..."
    Remove-Item -Path $sourceDirectory -Recurse -Force
    
    # Rename the temporary directory to replace WinSxS
    Rename-Item -Path $destinationDirectory -NewName "WinSxS"
    Write-Host "Complete!"
     
  16. wuliyen

    wuliyen MDL Novice

    Oct 6, 2009
    34
    55
    0
    Change this to your language code, _zh-cn_.
    Rename WinSxS folder
    New WinSxS folder
    Delete renamed folder after copying files
     
  17. SunLion

    SunLion MDL Addicted

    May 11, 2011
    952
    2,873
    30
    Good afternoon

    I don't know if you managed to solve the problem...

    I made some adjustments here. Try these and see if it works well for you.

    no password
     

    Attached Files:

  18. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    Good day, so far I haven't been able to solve the problem. Thank you very much, I'll try your version of the script.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. sainfo

    sainfo MDL Senior Member

    Dec 6, 2021
    322
    631
    10
    SunLion,
    I tested this version of the script, everything is fine - The operation completed successfully.
    Thank you very much for your efforts!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. Mavericks Choice

    Mavericks Choice MDL Guru

    Aug 5, 2015
    3,528
    14,541
    120
    @SunLion have tested fixed in a vm working perfectly here. Cheers.